decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
731 stars 289 forks source link

server: Prefer 3 min mix capable outbound peers. #3389

Closed davecgh closed 1 month ago

davecgh commented 1 month ago

The current logic attempts to maintain at least one mix capable outbound peer to ensure better connectivity among the mix capable peers. It works as intended, however, only having a single mix capable peer means there will be delays if that peer goes offline until a replacement is found. A possible consequence is that any mix clients might potentially get interrupted if that peer goes offline and a replacement isn't found quickly enough.

Attempting to maintain a minimum of three mix capable outbound peers will significantly reduce the likelihood of having periods without any mix capable peers.

This updates the logic accordingly.

[DBG] SRVR: Rejecting outbound peer <redacted> with protocol version 9 in favor of a peer with minimum version 10 (have: 0, target: 3)
...
[DBG] SRVR: Rejecting outbound peer <redacted> with protocol version 9 in favor of a peer with minimum version 10 (have: 2, target: 3)
...
$ dcrctl getpeerinfo | jq 'map(select(.version>=10)) | length'
3
davecgh commented 1 month ago

I shortened the debug message a bit per the edited PR description.