-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add function to update txpool on preconfirmation #2861
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
Conversation
| self.expired_transactions_and_dependents(tx_and_dependents_ids); | ||
| } | ||
| PoolTxUpdateRequest::PreconfirmedTransactions { txs } => { | ||
| self.preconfirmed_transactions(txs); |
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 pass an iterator instead?
| self.preconfirmed_transactions(txs); | |
| self.preconfirmed_transactions(txs.iter()); |
| } | ||
| } | ||
|
|
||
| fn preconfirmed_transactions(&mut self, txs: Vec<(TxId, PreconfirmationStatus)>) { |
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.
| fn preconfirmed_transactions(&mut self, txs: Vec<(TxId, PreconfirmationStatus)>) { | |
| fn preconfirmed_transactions(&mut self, txs: impl Iterator<Item = &(TxId, PreconfirmationStatus)>) { |
perhaps?
| } | ||
|
|
||
| fn remove_and_coin_dependents(&mut self, tx_ids: (Vec<TxId>, Error)) { | ||
| fn expired_transactions_and_dependents(&mut self, tx_ids: (Vec<TxId>, Error)) { |
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.
i think we can take an iterator here too, no?
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.
I don't like the type transformation it requires to write to make this works when calling this function because of the tuple, I would pass this one.
| #[derive(Clone)] | ||
| pub struct SharedState { | ||
| pub(crate) request_remove_sender: mpsc::Sender<PoolRemoveRequest>, | ||
| pub(crate) request_remove_sender: mpsc::Sender<PoolTxUpdateRequest>, |
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.
| pub(crate) request_remove_sender: mpsc::Sender<PoolTxUpdateRequest>, | |
| pub(crate) request_update_sender: mpsc::Sender<PoolTxUpdateRequest>, |
|
|
||
| pub fn notify_preconfirmed_txs(&self, txs: Vec<(TxId, PreconfirmationStatus)>) { | ||
| if let Err(e) = self | ||
| .request_remove_sender |
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.
| .request_remove_sender | |
| .request_update_sender |
| .collect(); | ||
|
|
||
| if let Err(e) = self | ||
| .request_remove_sender |
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.
| .request_remove_sender | |
| .request_update_sender |
| thread_management_sender: Sender<ThreadManagementRequest>, | ||
| pub(super) request_insert_sender: Sender<PoolInsertRequest>, | ||
| pub(super) request_remove_sender: Sender<PoolRemoveRequest>, | ||
| pub(super) request_remove_sender: Sender<PoolTxUpdateRequest>, |
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.
| pub(super) request_remove_sender: Sender<PoolTxUpdateRequest>, | |
| pub(super) request_update_sender: Sender<PoolTxUpdateRequest>, |
| pub fn new_known_tx<'a>( | ||
| &mut self, | ||
| new_known_tx: ArcPoolTx, | ||
| new_known_tx_outputs: impl Iterator<Item = &'a Output>, |
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.
perhaps this Output/iterator should be boxed?
difficult to say without knowing average size of outputs that we have, but in the case the user has 255 outputs this would be overusing the cache and move other imp code out of the cpu cache
since we have a limit on the total number of outputs, perhaps we can use smallvec?
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.
(i only write this because of the comment that says "we expect it to be called a lot")
|
|
||
| pub(super) enum PoolRemoveRequest { | ||
| pub(super) enum PoolTxUpdateRequest { | ||
| PreconfirmedTransactions { |
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.
I think instead of doing that, the transaction pool should subscribe for all pre-confirmation that comes from the TxStatusUpdater.
In that case you also don't need SkippedTransactions, because you will receive PreConfirmationSqueezedOut.
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.
I made this in a new PR (easier): #2882 . However it's still the service that receive the data and pass it to the worker if necessary to minimize the usage of the worker thread.
| | Output::Change { .. } | ||
| | Output::Variable { .. } => { |
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.
Resolved outputs only contain Change and Variable outputs=D
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.
BTW, we need to make a note to add an integration test to check that we can submit transaction that uses Change or Variable output form its parent after receiving a preconfiramtion
Linked Issues/PRs
Resolve #2860
Description
When a pre-confirmation status has arrived to the pool the pool can take action to updates some states
Checklist
Before requesting review