diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-10-23 22:09:26 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-10-23 22:09:26 +0800 |
| commit | cadbb7e78aca4378364c8d55503824fb55d30e38 (patch) | |
| tree | 30a858b9292e5abf8f311f2955a99634de8470cb | |
| parent | ee8daa37cb327d2f3fb011f54e0c566e0004435d (diff) | |
feat: bc verify command
API: HashChain::verify now takes Vec instead of &[]
| -rw-r--r-- | src/hash_chain.rs | 2 | ||||
| -rw-r--r-- | src/ui.rs | 20 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/hash_chain.rs b/src/hash_chain.rs index f21b1d2..e0ae1f2 100644 --- a/src/hash_chain.rs +++ b/src/hash_chain.rs @@ -53,7 +53,7 @@ impl<T: Encode> HashChain<T> { self.rehash(&base_hash); } - pub fn verify(&self, until_hash: &[u8]) -> bool { + pub fn verify(&self, until_hash: Vec<u8>) -> bool { let pos = self .data .iter() @@ -56,11 +56,21 @@ impl Ui { .get_blockchain() .clone() }; - println!( - "{:#?}", - bc.lock() - .await - ); + let bc = bc + .lock() + .await; + if let Some(cmd) = cmd.get(1) { + if *cmd == "verify" { + bc.verify( + bc.last() + .unwrap() + .0 + .clone(), + ); + } + } else { + println!("{:#?}", bc); + } } if cmd[0] == "peer" { |
