PubSub for IPC. (#5800)

This commit is contained in:
Tomasz Drwięga
2017-06-09 12:20:37 +02:00
committed by Gav Wood
parent d368006526
commit f86457ffd1
5 changed files with 18 additions and 24 deletions

View File

@@ -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))
);

View File

@@ -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(|_| ()));
},

View File

@@ -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))
);