5

The goal of the node would be to export its list of peers on an interval and publish it on IPNS to provide a dynamic bootstrap option for new peers. This helps if the static list published in a release gets deprecated.

Publishing to ipns seems doable with the offchain-ipfs feature. Where things are blurry is getting the list of peers from the chain.

I looked through the readme of sc_network and it mentions that the peerstore is being deprecated. If that is the case, how could one go about configuring a special node that can export it's list of connected peers on an interval? I suppose the "special" here could mean that only a well-known list of peerIDs are allowed to run this code, or other applicable access control methods.

From the little I know, substrate uses kademlia to manage connections. If that's the case, logic around filtering stale connections is already handled. In both cases though (is or is not kad), this list should be accessible in an environment where some comparison can be made with the current data on IPNS to perform some logic such as only publishing if the list changes.

1 Answer 1

4

You can get the list of currently connected peers by querying the NetworkWorker, peers_debug_info should provide you with the information you want. You might need to extend the NetworkService to expose this method (i.e. create an async method there that will send a message to NetworkWorker to call peers_debug_info).

This is also used to implement the system_peers RPC endpoint, so you can also look into how that's implemented.

1
  • Hi, I've looked into the service.rs of my node and I haven't been able to find the worker type. I'm working off of the node template and it seems they used a function to handle it that abstracts everything to a start method. How would I access it in this condition?
    – islami00
    Commented Mar 17, 2022 at 11:32

Your Answer

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

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