From ee8daa37cb327d2f3fb011f54e0c566e0004435d Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 22 Oct 2025 19:05:02 +0800 Subject: fix: usage of hash_chain fix: visibility of hash_chain funcs --- src/blocks.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/blocks.rs') diff --git a/src/blocks.rs b/src/blocks.rs index 53f9326..d1f287a 100644 --- a/src/blocks.rs +++ b/src/blocks.rs @@ -4,11 +4,7 @@ use std::ops::Deref; use serde::{Deserialize, Serialize}; -use crate::{ - ZERO_PREFIX_AMOUNT, - hash_chain::{self, HashChain}, - transaction::Transaction, -}; +use crate::{ZERO_PREFIX_AMOUNT, hash_chain::HashChain, transaction::Transaction}; use std::sync::{ Arc, @@ -134,17 +130,15 @@ impl BlockChain { } pub fn new_block(&self, trans: Transaction) -> Block { - let mut hasher = Sha256::new(); let prev = self .blocks .last(); let prev_hash = if let Some(b) = prev { - b.digest(&mut hasher); - Some(&*hasher.finalize()) + Some(HashChain::hash_o_item(b)) } else { None }; - Block::new(prev_hash, trans) + Block::new(prev_hash.as_deref(), trans) } pub fn store(&mut self, block: Block) { @@ -159,7 +153,7 @@ impl BlockChain { } impl Deref for BlockChain { - type Target = Vec; + type Target = HashChain; fn deref(&self) -> &Self::Target { &self.blocks -- cgit v1.2.3