mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Capture options with orphan block, fix #83
This commit is contained in:
parent
b3e224b439
commit
c994c7cba2
2 changed files with 6 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
Loading…
Reference in a new issue