From c994c7cba2aee1b26b035e8c01e4bee6b6e55bea Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Fri, 28 Jul 2017 02:21:00 +0000 Subject: [PATCH] Capture options with orphan block, fix #83 --- chain/src/chain.rs | 10 +++------- chain/src/types.rs | 5 +++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/chain/src/chain.rs b/chain/src/chain.rs index c860264d1..19e4fb128 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -53,7 +53,7 @@ pub struct Chain { head: Arc>, block_process_lock: Arc>, - orphans: Arc>>, + orphans: Arc>>, test_mode: bool, } @@ -134,7 +134,7 @@ impl Chain { } Err(Error::Orphan) => { let mut orphans = self.orphans.lock().unwrap(); - orphans.push_front(b); + orphans.push_front((opts, b)); orphans.truncate(MAX_ORPHANS); } _ => {} @@ -182,17 +182,13 @@ impl Chain { } // pop each orphan and retry, if still orphaned, will be pushed again - let mut opts = NONE; - if self.test_mode { - opts = opts | EASY_POW; - } for _ in 0..orphan_count { let mut popped = None; { let mut orphans = self.orphans.lock().unwrap(); popped = orphans.pop_back(); } - if let Some(orphan) = popped { + if let Some((opts, orphan)) = popped { self.process_block(orphan, opts); } } diff --git a/chain/src/types.rs b/chain/src/types.rs index 027003815..26dec7c4c 100644 --- a/chain/src/types.rs +++ b/chain/src/types.rs @@ -47,8 +47,6 @@ pub enum Error { DifficultyTooLow, /// Addition of difficulties on all previous block is wrong WrongTotalDifficulty, - /// Size of the Cuckoo graph in block header doesn't match PoW requirements - WrongCuckooSize, /// The proof of work is invalid InvalidPow, /// The block doesn't sum correctly or a tx signature is invalid @@ -59,7 +57,9 @@ pub enum Error { InvalidBlockHeight, /// Internal issue when trying to save or load data from store StoreErr(grin_store::Error), + /// Error serializing or deserializing a type SerErr(ser::Error), + /// Anything else Other(String), } @@ -199,6 +199,7 @@ pub trait ChainAdapter { fn block_accepted(&self, b: &Block); } +/// Dummy adapter used as a placeholder for real implementations pub struct NoopAdapter {} impl ChainAdapter for NoopAdapter { fn block_accepted(&self, b: &Block) {}