kaspanet / rusty-kaspa

Kaspa full-node and related libraries in the Rust programming language. This is a Beta version at the final testing phases.
ISC License
350 stars 105 forks source link

inbound eviction logic / policy. #431

Open D-Stacks opened 2 months ago

D-Stacks commented 2 months ago

This adds eviction logic and a policy to rusty-kaspa.

The idea is borrowed from btc and straight forward:

1) rank peers, by last_ping_duration, time_connected, last_tx_transfer (duration), last_block_transfer (duration), prefix_bucket (dispersal).

2) keep 40% of the best performing peers on any individual metric:

3) from the remaining peers, evicted peers are selected via a weighted choose function accounting for time-connected and prefix_bucket:

On the side, it also logs last tx transfer and last block transfer for each peer, as well as does a small overhaul on the PrefixBucket struct, (mostly inlining and refactoring).