Pending transactions subscription (#7906)

* Pending transactions subscription.

* Pending transactions Pub-Sub

* Add light client support.

* Remove redundant Ok
This commit is contained in:
Tomasz Drwięga
2018-02-16 16:51:34 +01:00
committed by Rando
parent 899dd0ff4b
commit 236a4aac22
6 changed files with 168 additions and 32 deletions

View File

@@ -295,7 +295,14 @@ impl FullDependencies {
Api::EthPubSub => {
if !for_generic_pubsub {
let client = EthPubSubClient::new(self.client.clone(), self.remote.clone());
self.client.add_notify(client.handler());
let h = client.handler();
self.miner.add_transactions_listener(Box::new(move |hashes| if let Some(h) = h.upgrade() {
h.new_transactions(hashes);
}));
if let Some(h) = client.handler().upgrade() {
self.client.add_notify(h);
}
handler.extend_with(client.to_delegate());
}
},
@@ -501,9 +508,13 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
self.remote.clone(),
self.gas_price_percentile,
);
self.client.add_listener(
Arc::downgrade(&client.handler()) as Weak<::light::client::LightChainNotify>
);
self.client.add_listener(client.handler() as Weak<_>);
let h = client.handler();
self.transaction_queue.write().add_listener(Box::new(move |transactions| {
if let Some(h) = h.upgrade() {
h.new_transactions(transactions);
}
}));
handler.extend_with(EthPubSub::to_delegate(client));
},
Api::Personal => {