add_sync_notifier in EthPubSubClient holds on to a Client for too long (#10689)
Need a weak ref so shutdown works
This commit is contained in:
parent
26d1303034
commit
d250f348a3
@ -64,14 +64,16 @@ impl<C> EthPubSubClient<C>
|
|||||||
where
|
where
|
||||||
F: 'static + Fn(SyncState) -> Option<pubsub::PubSubSyncStatus> + Send
|
F: 'static + Fn(SyncState) -> Option<pubsub::PubSubSyncStatus> + Send
|
||||||
{
|
{
|
||||||
let handler = self.handler.clone();
|
let weak_handler = Arc::downgrade(&self.handler);
|
||||||
|
|
||||||
self.handler.executor.spawn(
|
self.handler.executor.spawn(
|
||||||
receiver.for_each(move |state| {
|
receiver.for_each(move |state| {
|
||||||
if let Some(status) = f(state) {
|
if let Some(status) = f(state) {
|
||||||
|
if let Some(handler) = weak_handler.upgrade() {
|
||||||
handler.notify_syncing(status);
|
handler.notify_syncing(status);
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(())
|
Err(())
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user