move txpool reconcile_block to after block propagation in adapter (#2000)

This commit is contained in:
Antioch Peverell 2018-11-20 14:55:05 +00:00 committed by GitHub
parent 0eec80789a
commit e86eb641f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -651,14 +651,6 @@ impl ChainAdapter for ChainToPoolAndNetAdapter {
debug!("adapter: block_accepted: {:?}", b.hash());
if let Err(e) = self.tx_pool.write().reconcile_block(b) {
error!(
"Pool could not update itself at block {}: {:?}",
b.hash(),
e,
);
}
// If we mined the block then we want to broadcast the compact block.
// If we received the block from another node then broadcast "header first"
// to minimize network traffic.
@ -670,6 +662,16 @@ impl ChainAdapter for ChainToPoolAndNetAdapter {
// "header first" propagation if we are not the originator of this block
self.peers().broadcast_header(&b.header);
}
// Reconcile the txpool against the new block *after* we have broadcast it too our peers.
// This may be slow and we do not want to delay block propagation.
if let Err(e) = self.tx_pool.write().reconcile_block(b) {
error!(
"Pool could not update itself at block {}: {:?}",
b.hash(),
e,
);
}
}
}