Merge pull request #193 from ethcore/sync_receive_same_unknown_block_twice
Fixed issue when receiving same unknown block twice
This commit is contained in:
commit
b45ab2a06e
|
@ -1105,8 +1105,10 @@ impl<T> SynchronizationClientCore<T> where T: TaskExecutor {
|
||||||
// remove this block from the queue
|
// remove this block from the queue
|
||||||
chain.forget_block_leave_header(&block_hash);
|
chain.forget_block_leave_header(&block_hash);
|
||||||
// remember this block as unknown
|
// remember this block as unknown
|
||||||
|
if !self.orphaned_blocks_pool.contains_unknown_block(&block_hash) {
|
||||||
self.orphaned_blocks_pool.insert_unknown_block(block_hash, block);
|
self.orphaned_blocks_pool.insert_unknown_block(block_hash, block);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
BlockState::Verifying | BlockState::Stored => {
|
BlockState::Verifying | BlockState::Stored => {
|
||||||
// remember peer as useful
|
// remember peer as useful
|
||||||
|
@ -2212,4 +2214,15 @@ pub mod tests {
|
||||||
], ServerTaskIndex::None),
|
], ServerTaskIndex::None),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn receive_same_unknown_block_twice() {
|
||||||
|
let (_, _, _, _, sync) = create_sync(None, None);
|
||||||
|
|
||||||
|
let mut sync = sync.lock();
|
||||||
|
|
||||||
|
sync.on_peer_block(1, test_data::block_h2());
|
||||||
|
// should not panic here
|
||||||
|
sync.on_peer_block(2, test_data::block_h2());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue