Fixed sync stalling on a new block arriving while body request is pending
This commit is contained in:
parent
00b5fcebe3
commit
3fa1776ecf
@ -475,7 +475,7 @@ impl ChainSync {
|
|||||||
peer.latest_number = Some(header.number());
|
peer.latest_number = Some(header.number());
|
||||||
}
|
}
|
||||||
// TODO: Decompose block and add to self.headers and self.bodies instead
|
// TODO: Decompose block and add to self.headers and self.bodies instead
|
||||||
if header.number == From::from(self.current_base_block() + 1) {
|
if header.number <= From::from(self.current_base_block() + 1) {
|
||||||
match io.chain().import_block(block_rlp.as_raw().to_vec()) {
|
match io.chain().import_block(block_rlp.as_raw().to_vec()) {
|
||||||
Err(Error::Import(ImportError::AlreadyInChain)) => {
|
Err(Error::Import(ImportError::AlreadyInChain)) => {
|
||||||
trace!(target: "sync", "New block already in chain {:?}", h);
|
trace!(target: "sync", "New block already in chain {:?}", h);
|
||||||
@ -484,7 +484,10 @@ impl ChainSync {
|
|||||||
trace!(target: "sync", "New block already queued {:?}", h);
|
trace!(target: "sync", "New block already queued {:?}", h);
|
||||||
},
|
},
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
self.last_imported_block = Some(header.number);
|
if self.current_base_block() < header.number {
|
||||||
|
self.last_imported_block = Some(header.number);
|
||||||
|
self.remove_downloaded_blocks(header.number);
|
||||||
|
}
|
||||||
trace!(target: "sync", "New block queued {:?}", h);
|
trace!(target: "sync", "New block queued {:?}", h);
|
||||||
},
|
},
|
||||||
Err(Error::Block(BlockError::UnknownParent(p))) => {
|
Err(Error::Block(BlockError::UnknownParent(p))) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user