I am in the process of making the block handler modular (https://github.com/paritytech/substrate/pull/14014 pending now). We have this scenario:

  1. build_network() expects all the components constructed/passed in before the network is created
  2. If say one of these components needs a handle to the network (for example, to perform request/response), this becomes a problem: as the network is not yet created when the component is created.

We are resorting to some not so nice ways to work around this (e.g) the custom block handler has an Option<NetworkHandle<Block>>. This starts as None, eventually gets filled in with a valid handle, so on.

The sync layer internally works around this using NetworkServiceHandle, which is a wrapper around a channel send end point. But this doesn't work for external users. One possible solution would be to take Option<NetworkServiceHandle>(or something equivalent) during the build_network(), so the caller keeps a (cloned) copy of the handle for later use

1 Answer 1


I answered this on Github but we could use the recently-introduced FullNetworkConfiguration for storing the NetworkServiceProvider handle pair, add ability for protocols to allocate TX handles to the provider and then consume the RX handle in NetworkWorker. This would probably deprecate NetworkService so it's not a small task but this could possibly fix the issue you're having.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.