Skip to content

Commit

Permalink
Update cli.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 11, 2024
1 parent 73ec612 commit 0a21f2d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pi-nexus-blockchain/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// cli.rs (new)
// cli.rs (update)

use crate::blockchain::Blockchain;
use crate::transaction::Transaction;
Expand All @@ -18,16 +18,20 @@ fn main() {

let matches = app.get_matches();

let blockchain = Blockchain::new();
let mut blockchain = Blockchain::new();

match matches.value_of("command").unwrap() {
"create_transaction" => {
// TO DO: implement create transaction logic
println!("Create transaction command");
let sender = "Alice";
let recipient = "Bob";
let amount = 10;
let transaction = Transaction::new(sender, recipient, amount);
blockchain.add_transaction(transaction);
println!("Transaction created and added to the blockchain");
}
"add_block" => {
// TO DO: implement add block logic
println!("Add block command");
blockchain.add_block(blockchain.get_transactions());
println!("Block added to the blockchain");
}
"get_chain" => {
println!("Blockchain chain:");
Expand All @@ -37,4 +41,4 @@ fn main() {
}
_ => println!("Invalid command"),
}
}
}

0 comments on commit 0a21f2d

Please sign in to comment.