network icon indicating copy to clipboard operation
network copied to clipboard

refactor(dht): Rename `PeerManager#closestContacts`

Open teogeb opened this issue 1 year ago • 1 comments

Renamed PeerManager#closestContacts -> nearbyContacts. This way we can separate the concepts of:

  • nearby contacts (all currently known nodes having short Kademlia distance to this node)
  • closest contacts/neighbors/etc. (a subset of some contact list, e.g. 5 nearest neighbors)

Also renamed these to use term neighbor instead of bucket:

  • addClosestContactToBucket
  • getNearbyActiveContactNotInBucket
  • test description "Adds Nodes from layer1 KBucket to nearbyNodeView if its size is below nodeViewSize"

Also small refactoring in ContentDeliveryLayerNode#start.

Open questions

Why PeerManager#getClosestRingContactsTo returns also nearby contacts?

teogeb avatar Apr 22 '24 09:04 teogeb

Why PeerManager#getClosestRingContactsTo returns also nearby contacts?

Apparently it adds all nearbyContacts to the sorted list before returning. This should not be necessary since the new contacts should be added to the structures at the same time. So this logic could be removed.

Whenever there is a reference to kbucket / bucket rename to neighbors

juslesan avatar Apr 22 '24 12:04 juslesan