-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Watch transactions pool #10558
Watch transactions pool #10558
Changes from all commits
2c4034f
458a85b
79e3afe
dc6d4e0
d68e4c7
055021d
629c590
d908a39
591b14e
ea12cd5
286ba53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,17 +22,18 @@ use std::sync::atomic::{self, AtomicUsize}; | |
| use std::collections::{BTreeMap, BTreeSet, HashMap}; | ||
|
|
||
| use ethereum_types::{H256, U256, Address}; | ||
| use futures::sync::mpsc; | ||
| use parking_lot::RwLock; | ||
| use txpool::{self, Verifier}; | ||
| use types::transaction; | ||
|
|
||
| use pool::{ | ||
| self, replace, scoring, verifier, client, ready, listener, | ||
| PrioritizationStrategy, PendingOrdering, PendingSettings, | ||
| PrioritizationStrategy, PendingOrdering, PendingSettings, TxStatus | ||
| }; | ||
| use pool::local_transactions::LocalTransactionsList; | ||
|
|
||
| type Listener = (LocalTransactionsList, (listener::Notifier, listener::Logger)); | ||
| type Listener = (LocalTransactionsList, (listener::Notifier, (listener::Logger, listener::TransactionsPoolNotifier))); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That starts to look pretty ugly, we could have a macro in |
||
| type Pool = txpool::Pool<pool::VerifiedTransaction, scoring::NonceAndGasPrice, Listener>; | ||
|
|
||
| /// Max cache time in milliseconds for pending transactions. | ||
|
|
@@ -304,6 +305,8 @@ impl TransactionQueue { | |
| // Notify about imported transactions. | ||
| (self.pool.write().listener_mut().1).0.notify(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This listener now seems obsolete, since it just duplicates the same data and is less efficient than the new channel-based one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ok, then let`s do it in other PR
Maybe we can make one Notifier by combining old one |
||
|
|
||
| ((self.pool.write().listener_mut().1).1).1.notify(); | ||
|
|
||
| if results.iter().any(|r| r.is_ok()) { | ||
| self.cached_pending.write().clear(); | ||
| } | ||
|
|
@@ -574,6 +577,12 @@ impl TransactionQueue { | |
| (pool.listener_mut().1).0.add(f); | ||
| } | ||
|
|
||
| /// Add a listener to be notified about all transactions the pool | ||
| pub fn add_tx_pool_listener(&self, f: mpsc::UnboundedSender<Arc<Vec<(H256, TxStatus)>>>) { | ||
| let mut pool = self.pool.write(); | ||
| ((pool.listener_mut().1).1).1.add(f); | ||
| } | ||
|
|
||
| /// Check if pending set is cached. | ||
| #[cfg(test)] | ||
| pub fn is_pending_cached(&self) -> bool { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.