Skip to content

Setting a Node involves NodeManager and NodeGraph, where NodeManager handles bucket overflow policy #359

@tegefaulkes

Description

@tegefaulkes

Specification

Adding a node to a NodeGraph's bucket needs to be updated. There are 3 cases when adding a node that need to be handled

  1. If the node already exists in the bucket the last updated need to be updated.
  2. If the node is not already in the bucket AND the bucket has room. The node is added into the bucket.
  3. If the node is not in the bucket AND the bucket is full. We need to ping the oldest node in the bucket, if the old node does not respond we drop it for the new node, otherwise we drop the new node and update the last updated for the old node.

We need to add a force flag for always add the new node for manually adding nodes.

The core of the functionality needs to be moved into the NodeManager. since the NodeGraph is purely data structure the checking of the nodes before adding them should be handled inside the NodeManager.

As implemented, the NodeGraph just stores the nodes within buckets and tracks the number of nodes in the bucket. The more complex logic is handled by the NodeManager now.

Additional context

Tasks

  • 1. Remove bucket limit checking and core adding logic from NodeGraph to NodeManager.addNode method. NodeGraph is purely data-structure anything that requires complex checking or networking needs to be outside it.
  • 2. Handle cases when adding a node.
    1. Node already exists.
    2. Node exists, bucket has room.
    3. Node exist, bucket is full.
  • 3. Add force parameter to force adding a node if bucket is full.
  • Update testing.
    • fix any tests broken by logic moving to NodeManager
    • add test for the 3 cases when adding nodes.
    • add test for force parameter

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions