probe-lab / zikade

A Go implementation of the libp2p Kademlia DHT specification
Other
12 stars 3 forks source link

Cleanup idle NodeHandlers #70

Open iand opened 1 year ago

iand commented 1 year ago

The NetworkBehaviour maintains a map of NodeHandler but entries are never deleted from this map. Each NodeHandler maintains a goroutine to process events from other state machines that want to send messages to the node. Deleting an idle NodeHandler from the map is safe since its only state is the queue of events waiting to be processed.

A NodeHandler should be removed from the map when:

  1. the node is removed from the routing table
  2. no communication has been requested for a configurable period of time

When the NodeHandler is deleted the goroutine servicing its work queue should also be stopped.