@@ -733,43 +733,45 @@ fn handle_message(our: &Address, state: &mut State, message: &Message) -> anyhow
733733 } else {
734734 if message. source ( ) . process == "eth:distro:sys" {
735735 let eth_result = serde_json:: from_slice :: < eth:: EthSubResult > ( message. body ( ) ) ?;
736- if let Ok ( eth:: EthSub { id, result } ) = eth_result {
737- if let Ok ( eth:: SubscriptionResult :: Log ( ref log) ) =
738- serde_json:: from_value :: < eth:: SubscriptionResult > ( result)
739- {
740- // Determine which subscription this is from
741- // Note: log is Box<eth::Log>, we need to dereference it
742- let log_ref: & eth:: Log = & * * log;
743- let context = if id == SUBSCRIPTION_NUMBER {
744- LogContext :: Hypermap ( log_ref. clone ( ) )
745- } else if id == BINDINGS_SUBSCRIPTION {
746- LogContext :: Bindings ( log_ref. clone ( ) )
747- } else {
748- return Ok ( false ) ; // Unknown subscription
749- } ;
750- // delay handling of ETH RPC subscriptions by DELAY_MS
751- // to allow hns to have a chance to process block
752- timer:: set_timer ( DELAY_MS , Some ( serde_json:: to_vec ( & context) ?) ) ;
736+ match eth_result {
737+ Ok ( eth:: EthSub { id, result } ) => {
738+ if let Ok ( eth:: SubscriptionResult :: Log ( ref log) ) =
739+ serde_json:: from_value :: < eth:: SubscriptionResult > ( result)
740+ {
741+ // Determine which subscription this is from
742+ // Note: log is Box<eth::Log>, we need to dereference it
743+ let log_ref: & eth:: Log = & * * log;
744+ let context = if id == SUBSCRIPTION_NUMBER {
745+ LogContext :: Hypermap ( log_ref. clone ( ) )
746+ } else if id == BINDINGS_SUBSCRIPTION {
747+ LogContext :: Bindings ( log_ref. clone ( ) )
748+ } else {
749+ return Ok ( false ) ; // Unknown subscription
750+ } ;
751+ // delay handling of ETH RPC subscriptions by DELAY_MS
752+ // to allow hns to have a chance to process block
753+ timer:: set_timer ( DELAY_MS , Some ( serde_json:: to_vec ( & context) ?) ) ;
754+ }
755+ }
756+ Err ( err) => {
757+ if err. id == SUBSCRIPTION_NUMBER {
758+ let _ = state. hypermap . provider . unsubscribe ( SUBSCRIPTION_NUMBER ) ;
759+ state. hypermap . provider . subscribe_loop (
760+ SUBSCRIPTION_NUMBER ,
761+ app_store_filter ( state) ,
762+ 1 ,
763+ 0 ,
764+ ) ;
765+ } else if err. id == BINDINGS_SUBSCRIPTION {
766+ let _ = state. bindings . provider . unsubscribe ( BINDINGS_SUBSCRIPTION ) ;
767+ state. bindings . provider . subscribe_loop (
768+ BINDINGS_SUBSCRIPTION ,
769+ bindings_filter ( & state. bindings ) ,
770+ 1 ,
771+ 0 ,
772+ ) ;
773+ }
753774 }
754- } else {
755- // unsubscribe to make sure we have cleaned up after ourselves;
756- // drop Result since we don't care if no subscription exists,
757- // just being diligent in case it does!
758- let _ = state. hypermap . provider . unsubscribe ( SUBSCRIPTION_NUMBER ) ;
759- let _ = state. bindings . provider . unsubscribe ( BINDINGS_SUBSCRIPTION ) ;
760- // re-subscribe if error
761- state. hypermap . provider . subscribe_loop (
762- SUBSCRIPTION_NUMBER ,
763- app_store_filter ( state) ,
764- 1 ,
765- 0 ,
766- ) ;
767- state. bindings . provider . subscribe_loop (
768- BINDINGS_SUBSCRIPTION ,
769- bindings_filter ( & state. bindings ) ,
770- 1 ,
771- 0 ,
772- ) ;
773775 }
774776 } else {
775777 let req = serde_json:: from_slice :: < ChainRequest > ( message. body ( ) ) ?;
0 commit comments