mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-24 03:45:38 +08:00
working local-only cli
This commit is contained in:
@@ -9,6 +9,14 @@ description = "Reference implementation of Blockstack Core"
|
||||
keywords = [ "bitcoin", "crypto", "blockstack", "decentralized", "dapps", "blockchain" ]
|
||||
readme = "README.md"
|
||||
|
||||
[[bin]]
|
||||
name = "blockstack-core"
|
||||
path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "clarity"
|
||||
path = "src/clarity_cli.rs"
|
||||
|
||||
[features]
|
||||
developer-mode = []
|
||||
default = ["developer-mode"]
|
||||
|
||||
12
Dockerfile
12
Dockerfile
@@ -1,19 +1,7 @@
|
||||
FROM rust:latest
|
||||
|
||||
WORKDIR /src/
|
||||
|
||||
# Hacks to cache the build dependencies.
|
||||
|
||||
RUN USER=root cargo new --bin blockstack-core
|
||||
WORKDIR /src/blockstack-core
|
||||
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
|
||||
RUN cargo build --release
|
||||
RUN rm src/*.rs
|
||||
RUN rm ./target/release/deps/blockstack_core*
|
||||
|
||||
# copy your source tree
|
||||
COPY . .
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
@@ -28,7 +28,7 @@ where command is one of:
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
pub fn invoke_command(invoked_by: &str, args: &[String]) {
|
||||
if args.len() < 1 {
|
||||
print_usage(invoked_by)
|
||||
}
|
||||
@@ -44,7 +44,6 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
Ok(_) => println!("Database created."),
|
||||
Err(error) => eprintln!("Initialization error: \n {}", error)
|
||||
}
|
||||
return Some(())
|
||||
},
|
||||
"set_block_height" => {
|
||||
if args.len() < 3 {
|
||||
@@ -66,8 +65,6 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
sp.set_simmed_block_height(blockheight);
|
||||
sp.commit();
|
||||
println!("Simulated block height updated!");
|
||||
|
||||
return Some(())
|
||||
},
|
||||
"check" => {
|
||||
if args.len() < 2 {
|
||||
@@ -93,8 +90,6 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
eprintln!("Type check error.\n{}", e);
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
return Some(())
|
||||
},
|
||||
"eval" => {
|
||||
if args.len() < 3 {
|
||||
@@ -142,7 +137,6 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
},
|
||||
Err(error) => println!("Program execution error: \n {}", error)
|
||||
}
|
||||
return Some(())
|
||||
},
|
||||
"launch" => {
|
||||
if args.len() < 4 {
|
||||
@@ -207,7 +201,6 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
},
|
||||
Err(error) => println!("Contract initialization error: \n {}", error)
|
||||
}
|
||||
return Some(())
|
||||
},
|
||||
"execute" => {
|
||||
if args.len() < 5 {
|
||||
@@ -276,17 +269,9 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> Option<()> {
|
||||
},
|
||||
Err(error) => println!("Transaction execution error: \n {}", error),
|
||||
}
|
||||
return Some(())
|
||||
},
|
||||
_ => {
|
||||
return None
|
||||
print_usage(invoked_by)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
log::set_loglevel(log::LOG_DEBUG).unwrap();
|
||||
let argv : Vec<String> = env::args().collect();
|
||||
|
||||
invoke_command(&argv[0], &argv[1..]);
|
||||
}
|
||||
|
||||
71
src/clarity_cli.rs
Normal file
71
src/clarity_cli.rs
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
copyright: (c) 2013-2018 by Blockstack PBC, a public benefit corporation.
|
||||
|
||||
This file is part of Blockstack.
|
||||
|
||||
Blockstack is free software. You may redistribute or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License or
|
||||
(at your option) any later version.
|
||||
|
||||
Blockstack is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY, including without the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Blockstack. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_assignments)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
extern crate rand;
|
||||
extern crate ini;
|
||||
extern crate secp256k1;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate rusqlite;
|
||||
extern crate curve25519_dalek;
|
||||
extern crate ed25519_dalek;
|
||||
extern crate sha2;
|
||||
extern crate ripemd160;
|
||||
extern crate dirs;
|
||||
extern crate regex;
|
||||
extern crate byteorder;
|
||||
extern crate mio;
|
||||
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
#[macro_use]
|
||||
mod util;
|
||||
|
||||
#[macro_use]
|
||||
mod chainstate;
|
||||
|
||||
mod address;
|
||||
mod burnchains;
|
||||
mod core;
|
||||
mod deps;
|
||||
mod net;
|
||||
mod vm;
|
||||
|
||||
mod clarity;
|
||||
|
||||
use std::fs;
|
||||
use std::env;
|
||||
use std::process;
|
||||
|
||||
use util::log;
|
||||
|
||||
fn main() {
|
||||
log::set_loglevel(log::LOG_DEBUG).unwrap();
|
||||
let argv : Vec<String> = env::args().collect();
|
||||
|
||||
clarity::invoke_command(&argv[0], &argv[1..]);
|
||||
}
|
||||
@@ -123,9 +123,8 @@ fn main() {
|
||||
}
|
||||
|
||||
if argv[1] == "local" {
|
||||
if clarity::invoke_command(&format!("{} {}", argv[0], argv[1]), &argv[2..]).is_some() {
|
||||
return
|
||||
}
|
||||
clarity::invoke_command(&format!("{} {}", argv[0], argv[1]), &argv[2..]);
|
||||
return
|
||||
}
|
||||
|
||||
if argv.len() < 4 {
|
||||
|
||||
Reference in New Issue
Block a user