From 9a11f527a30be0ab72c40f957a283d646feca005 Mon Sep 17 00:00:00 2001 From: dancoombs Date: Thu, 5 Oct 2023 11:12:32 -0400 Subject: [PATCH] fix(pool): remove insert dup, scope write lock --- crates/pool/src/mempool/uo_pool.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/pool/src/mempool/uo_pool.rs b/crates/pool/src/mempool/uo_pool.rs index 0b8c224e0..bfa9fe20e 100644 --- a/crates/pool/src/mempool/uo_pool.rs +++ b/crates/pool/src/mempool/uo_pool.rs @@ -258,12 +258,15 @@ where }; // Add op to pool - let mut state = self.state.write(); - let hash = state.pool.add_operation(pool_op.clone())?; - let bn = state.block_number; - if throttled { - state.throttled_ops.insert(hash, bn); - } + let (hash, bn) = { + let mut state = self.state.write(); + let hash = state.pool.add_operation(pool_op.clone())?; + let bn = state.block_number; + if throttled { + state.throttled_ops.insert(hash, bn); + } + (hash, bn) + }; // Update reputation pool_op @@ -272,11 +275,6 @@ where .unique() .for_each(|a| self.reputation.add_seen(a)); - // If an entity was throttled, track with throttled ops - if throttled { - state.throttled_ops.insert(hash, bn); - } - let op_hash = pool_op.uo.op_hash(self.entry_point, self.chain_id); let valid_after = pool_op.valid_time_range.valid_after; let valid_until = pool_op.valid_time_range.valid_until;