-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(mempool): implement remove method for transaction queue #412
feat(mempool): implement remove method for transaction queue #412
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #412 +/- ##
==========================================
- Coverage 83.69% 83.40% -0.30%
==========================================
Files 37 37
Lines 1717 1723 +6
Branches 1717 1723 +6
==========================================
Hits 1437 1437
- Misses 203 209 +6
Partials 77 77 ☔ View full report in Codecov by Sentry. |
331b790
to
3d2f02c
Compare
8723580
to
3b579de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/transaction_queue.rs
line 52 at r2 (raw file):
} /// At most one transaction is associated with a single address in the queue.
Suggestion:
/// Removes the transaction of the given account address from the queue.
/// This is well-defined, since there is at most one transaction per address in the queue.
crates/mempool/src/transaction_queue.rs
line 53 at r2 (raw file):
/// At most one transaction is associated with a single address in the queue. pub fn _remove(mut self, address: &ContractAddress) -> Option<TransactionReference> {
Temporary name until used?
Code quote:
_remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/transaction_queue.rs
line 53 at r2 (raw file):
/// At most one transaction is associated with a single address in the queue. pub fn _remove(mut self, address: &ContractAddress) -> Option<TransactionReference> {
Pass self
by reference, while address
is Copy
so no need.
Suggestion:
&mut self, address: ContractAddress
3d2f02c
to
4fd12e9
Compare
3b579de
to
c4e5e4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/transaction_queue.rs
line 53 at r2 (raw file):
Previously, elintul (Elin) wrote…
Temporary name until used?
Exactly
crates/mempool/src/transaction_queue.rs
line 53 at r2 (raw file):
Previously, elintul (Elin) wrote…
Pass
self
by reference, whileaddress
isCopy
so no need.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @MohammadNassar1)
crates/mempool/src/transaction_queue.rs
line 58 at r3 (raw file):
self.queue.remove(&tx.into()); tx })
I like the chaining attempt, but it's best to keep side-effects away from map
; it's intended goal is for transformation, rather than side-effects.
Suggestion:
let tx = self.address_to_tx.remove(&address)?
self.queue.remove(&tx.into());
tx
/// Technically this will also work, but this feels more complicated.
// let tx = self.address_to_tx.remove(&address)?;
// self.queue.take(&tx.into()).map(|tx| tx.0)
c4e5e4b
to
1cc6e11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/transaction_queue.rs
line 58 at r3 (raw file):
Previously, giladchase wrote…
I like the chaining attempt, but it's best to keep side-effects away from
map
; it's intended goal is for transformation, rather than side-effects.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @elintul)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
1cc6e11
to
7ad7726
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware and @MohammadNassar1)
crates/mempool/src/transaction_queue.rs
line 54 at r5 (raw file):
/// Removes the transaction of the given account address from the queue. /// This is well-defined, since there is at most one transaction per address in the queue. pub fn _remove(&mut self, address: ContractAddress) -> Option<TransactionReference> {
I don't think we should return the reference, maybe a bool
is enough?
Code quote:
Option<TransactionReference>
7ad7726
to
e56b0d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/transaction_queue.rs
line 54 at r5 (raw file):
Previously, elintul (Elin) wrote…
I don't think we should return the reference, maybe a
bool
is enough?
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ayeletstarkware and @giladchase)
crates/mempool/src/transaction_queue.rs
line 54 at r5 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Done
WDYT about:
self.address_to_tx.remove(&address).map_or(false, |tx| self.queue.remove(&tx.into()))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/transaction_queue.rs
line 54 at r5 (raw file):
Previously, elintul (Elin) wrote…
WDYT about:
self.address_to_tx.remove(&address).map_or(false, |tx| self.queue.remove(&tx.into()))
But we said that we dont use map
in this case, right?
and it's not a simple logic, it has a side effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
crates/mempool/src/transaction_queue.rs
line 54 at r5 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
But we said that we dont use
map
in this case, right?
and it's not a simple logic, it has a side effect.
It's the or
branch, the map
side is pure. @giladchase - WDYT?
This change is