summaryrefslogtreecommitdiff
path: root/src/blocks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/blocks.rs')
-rw-r--r--src/blocks.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/blocks.rs b/src/blocks.rs
index 57fbab8..53f9326 100644
--- a/src/blocks.rs
+++ b/src/blocks.rs
@@ -4,7 +4,11 @@ use std::ops::Deref;
use serde::{Deserialize, Serialize};
-use crate::{ZERO_PREFIX_AMOUNT, transaction::Transaction};
+use crate::{
+ ZERO_PREFIX_AMOUNT,
+ hash_chain::{self, HashChain},
+ transaction::Transaction,
+};
use std::sync::{
Arc,
@@ -29,7 +33,7 @@ impl Block {
Self {
prev_hash: prev_hash
.unwrap_or(&[])
- .to_vec(), // special blocks
+ .to_vec(),
trans,
pow: None,
}
@@ -79,7 +83,6 @@ impl Block {
}
break;
}
- println!("{i}");
i = i.wrapping_add(step);
}
});
@@ -120,13 +123,13 @@ impl CryptoDigest for Block {
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)]
pub struct BlockChain {
- pub blocks: Vec<Block>,
+ pub blocks: HashChain<Block>,
}
impl BlockChain {
pub fn new(blocks: Vec<Block>) -> Self {
Self {
- blocks,
+ blocks: HashChain::new(blocks),
}
}