probe-lab / zikade

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

Cleanup idle NodeHandlers #70

Open iand opened 8 months ago

iand commented 8 months 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.