You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
I am in the process of making the block handler modular (#14014 pending now). We have the following scenario:
build_network() expects all the components constructed/passed in before the network is created
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(or something equivalent) during the build_network(), so the caller keeps a (cloned) copy of the handle for later use
NetworkServiceProvider was never meant to be anything but a temporary hack to get things moving but the current design we're slowing working sc-network towards requires this kind of usage pattern so I think it's here to stay.
We recently introduced FullNetworkConfiguration which contains protocol information that sc-network must be allowed to consume (so no cloning). What you're proposing could fit into this scheme and when FullNetworkConfiguration is created, it would create NetworkServiceProvider and a way for protocols to allocate handles to the provider. Finally when the configuration reaches NetworkWorker, it would consume the reader half of the handle. This way the indirection in NetworkServiceProvider could be removed and I guess NetworkService would be replaced because NetworkWorker would be now listening to NetworkServiceProvider.
FullNetworkConfiguration is created in the node CLI service, so for example bin/node/cli/src/service.rs. Is this early enough for your use case?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am in the process of making the block handler modular (#14014 pending now). We have the following scenario:
build_network()
expects all the components constructed/passed in before the network is createdIf 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(or something equivalent) during the
build_network()
, so the caller keeps a (cloned) copy of the handle for later useAlso posted on stack exchange previously: https://substrate.stackexchange.com/questions/8470/circular-dependency
Beta Was this translation helpful? Give feedback.
All reactions