Skip to content

Commit

Permalink
fix(pool): remove insert dup, scope write lock
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Oct 5, 2023
1 parent 22fc250 commit 9a11f52
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions crates/pool/src/mempool/uo_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 9a11f52

Please sign in to comment.