-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
dev(pool): trait object safe BestTransactions
#10478
dev(pool): trait object safe BestTransactions
#10478
Conversation
9b271e2
to
572836e
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.
that makes sense, but the test should actually use the trait function
// Create a filter that only returns transactions with even nonces | ||
let filter = | ||
BestTransactionFilter::new(best, |tx: &Arc<ValidPoolTransaction<MockTransaction>>| { | ||
tx.nonce() % 2 == 0 | ||
}); |
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.
this should use the trait function on best
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.
Do you mean the trait function filter
? I can't use it because of the Sized
requirement
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.
ah I see, then this won't be very useful because we usually operate on Box<dyn
and won't be much different from the previous impl right? so what does this change actually achieve?
@@ -162,6 +164,8 @@ impl<T: TransactionOrdering> crate::traits::BestTransactions for BestTransaction | |||
} | |||
} | |||
|
|||
impl<T: TransactionOrdering> crate::traits::BestTransactionsFilter for BestTransactions<T> {} |
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.
can we try replacing this with a blanket impl
filter for T where T: BestTransaction
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.
this makes a lot of sense and seems possible, will add
// Create a filter that only returns transactions with even nonces | ||
let filter = | ||
BestTransactionFilter::new(best, |tx: &Arc<ValidPoolTransaction<MockTransaction>>| { | ||
tx.nonce() % 2 == 0 | ||
}); |
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.
ah I see, then this won't be very useful because we usually operate on Box<dyn
and won't be much different from the previous impl right? so what does this change actually achieve?
The idea was to make this work for a This builds towards #10437, making it then possible to filter the transactions returned by Let me know if this makes sense or if you would rather change something. |
gotcha, now I understood. is this possible if not this is complete |
572836e
to
82b3f50
Compare
BestTransactions
in two traits in order to make theBestTransactions
trait object safe.BestTransactionsFilter
trait object that verifies that the predicates only keeps transactions with even nonces.