Capture options with orphan block, fix #83
This commit is contained in:
+3
-7
@@ -53,7 +53,7 @@ pub struct Chain {
|
||||
|
||||
head: Arc<Mutex<Tip>>,
|
||||
block_process_lock: Arc<Mutex<bool>>,
|
||||
orphans: Arc<Mutex<VecDeque<Block>>>,
|
||||
orphans: Arc<Mutex<VecDeque<(Options, Block)>>>,
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user