Skip to content

CloserPeers, Peer Usefulness and PrunableMetadata Caching - #22

Merged
btoms20 merged 9 commits into
mainfrom
misc-work
Sep 2, 2026
Merged

CloserPeers, Peer Usefulness and PrunableMetadata Caching#22
btoms20 merged 9 commits into
mainfrom
misc-work

Conversation

@btoms20

@btoms20 btoms20 commented Sep 2, 2026

Copy link
Copy Markdown
Member

What?

This PR contains fixes for our closerPeers calculation, wires in a peer usefulness metric, caches PrunableMetadata values (instead of JSON encoding them on the fly), and refactored our RoutingTable's add / remove peer methods.

Changes:

  • CloserPeers: when calculating our closerPeers in responses to a .findNode query, we consult our global PeerStore and prepend the peer if we know of them. Without consulting the PeerStore, we would only ever return results for other KadDHT query peers (peers that made it into our RoutingTable).
  • Usefulness: we now mark peers in our RoutingTable as useful when they respond to our queries with a list of closer peers. We prefer these peers over stale ones when evicting peers from our RoutingTable.
  • Add/Remove RT Refactor: Previously we had two very similar implementations of our add / remove peer methods in our RoutingTable to handle a PeerID and DHTPeerInfo. Now we have a single _insert method and a cleaner replacement strategy / eviction method.
  • Cache PrunableMetadata: Previously we were re-encoding our PrunableMetadata values every time we accessed the peers metadata. Now, we encode once, store in a static constant and compare the bytes directly.

@btoms20 btoms20 self-assigned this Sep 2, 2026
@btoms20 btoms20 added bug Something isn't working enhancement New feature or request labels Sep 2, 2026
@btoms20
btoms20 merged commit bbf7219 into main Sep 2, 2026
28 checks passed
@btoms20
btoms20 deleted the misc-work branch September 2, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant