Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pool): remove insert dup, scope write lock #446

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading