From e86eb641f1870e96019e0e5d2f83003eeff3d495 Mon Sep 17 00:00:00 2001 From: Antioch Peverell Date: Tue, 20 Nov 2018 14:55:05 +0000 Subject: [PATCH] move txpool reconcile_block to after block propagation in adapter (#2000) --- servers/src/common/adapters.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/servers/src/common/adapters.rs b/servers/src/common/adapters.rs index bbff07deb..a8e4c864e 100644 --- a/servers/src/common/adapters.rs +++ b/servers/src/common/adapters.rs @@ -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, + ); + } } }