VeriBlock / nodecore

Other
12 stars 16 forks source link

Improve peer discovery mechanism #347

Open Warchant opened 2 years ago

Warchant commented 2 years ago

Fixes https://github.com/VeriBlock/vbk-ri-btc/issues/630

blackyblack commented 2 years ago

@Warchant do you have a list of peers that we want to hardcode?

Warchant commented 2 years ago

@blackyblack it turns out mainnet NC does DNS resolution to get peers. And it is already implemented in APM. Just make sure for (1) that all peers found by DNS resolution are used.

blackyblack commented 2 years ago

I see that DNS IPs are added to the peers table as soon as they are resolved. And we have such a test case for a single IP for a single DNS record. Should we consider (1) as done then? As for (2), I haven't found the ability to download peers list from the connected peers. Should I implement this functionality?

blackyblack commented 2 years ago

For (2) scratch this. Found some code that looks like it.

blackyblack commented 2 years ago

@Warchant Also I found that peers may stay in candidates list but not being connected to. It happens if minimum amount of peers has been reached. Do we want to fix this behavior?

Warchant commented 2 years ago

@blackyblack

  1. SPV should maintain minpeers active connections. It should connect connect up until minpeers is reached, then we can accept only incoming connections up until maxpeers.
  2. regularly check connection status. Is there a "ping" p2p command or something?
  3. Set default minpeers to 5
blackyblack commented 2 years ago

@Warchant

  1. Well it seems it already works this way.
  2. Yes, it regularly checks for peers' last received message.
  3. It is set to 8 now.
Warchant commented 2 years ago

@blackyblack wow. Okay. Do you have any idea why this may happen https://github.com/VeriBlock/nodecore/issues/369 ?

blackyblack commented 2 years ago

I was looking at the nodecore peer discovery code and the logs are for SPV app. I will check if there is any difference.