PubSub for IPC. (#5800)
This commit is contained in:
@@ -74,10 +74,10 @@ impl<C> ChainNotificationHandler<C> {
|
||||
for subscriber in self.heads_subscribers.lock().values() {
|
||||
for &(ref block, ref extra_info) in &blocks {
|
||||
self.remote.spawn(subscriber
|
||||
.notify(pubsub::Result::Header(RichHeader {
|
||||
.notify(Ok(pubsub::Result::Header(RichHeader {
|
||||
inner: block.into(),
|
||||
extra_info: extra_info.clone(),
|
||||
}))
|
||||
})))
|
||||
.map(|_| ())
|
||||
.map_err(|e| warn!(target: "rpc", "Unable to send notification: {}", e))
|
||||
);
|
||||
|
||||
@@ -72,13 +72,7 @@ impl<S: core::Middleware<Metadata>> PubSub for PubSubClient<S> {
|
||||
let (id, receiver) = poll_manager.subscribe(meta, method, params);
|
||||
match subscriber.assign_id(id.clone()) {
|
||||
Ok(sink) => {
|
||||
self.remote.spawn(receiver.map(|res| match res {
|
||||
Ok(val) => val,
|
||||
Err(error) => {
|
||||
warn!(target: "pubsub", "Subscription error: {:?}", error);
|
||||
core::Value::Null
|
||||
},
|
||||
}).forward(sink.sink_map_err(|e| {
|
||||
self.remote.spawn(receiver.forward(sink.sink_map_err(|e| {
|
||||
warn!("Cannot send notification: {:?}", e);
|
||||
})).map(|_| ()));
|
||||
},
|
||||
|
||||
@@ -61,7 +61,7 @@ impl<D: Dispatcher + 'static> SignerClient<D> {
|
||||
for subscription in subs.lock().values() {
|
||||
let subscription: &Sink<_> = subscription;
|
||||
remote.spawn(subscription
|
||||
.notify(requests.clone())
|
||||
.notify(Ok(requests.clone()))
|
||||
.map(|_| ())
|
||||
.map_err(|e| warn!(target: "rpc", "Unable to send notification: {}", e))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user