diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-10-21 09:56:21 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-10-21 09:56:28 +0800 |
| commit | f754675aac96ac04599ec79d609e2c5b08be4561 (patch) | |
| tree | a92a2e4b910593d3593744dd99bae0ba28a44c37 /src/blocks.rs | |
| parent | b71fae628d97ada84c533ce746d4d7980a9f6d73 (diff) | |
feat: ui
Diffstat (limited to 'src/blocks.rs')
| -rw-r--r-- | src/blocks.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/blocks.rs b/src/blocks.rs index 288e754..84f6c92 100644 --- a/src/blocks.rs +++ b/src/blocks.rs @@ -84,6 +84,19 @@ impl BlockChain { } } + pub fn new_block(&self, trans: Transaction) -> Block { + let mut hasher = DefaultHasher::new(); + Block::new( + self.blocks + .last() + .map(|b| { + b.hash(&mut hasher); + hasher.finish() + }), + trans, + ) + } + pub fn store(&mut self, block: Block) { // TODO: verify blocks self.blocks |
