Пример #1
0
        public void Newly_added_can_be_retrieved_as_bonded()
        {
            NodeBucket nodeBucket = new NodeBucket(1, 16);

            nodeBucket.AddNode(_node);
            nodeBucket.AddNode(_node2);
            nodeBucket.AddNode(_node3);
            nodeBucket.BondedItems.Should().HaveCount(3);
        }
Пример #2
0
        public void Bonded_count_is_tracked()
        {
            NodeBucket nodeBucket = new NodeBucket(1, 16);

            nodeBucket.AddNode(_node);
            nodeBucket.AddNode(_node2);
            nodeBucket.AddNode(_node3);
            nodeBucket.BondedItemsCount.Should().Be(3);
        }
Пример #3
0
        private static void AddNodes(NodeBucket nodeBucket, int count)
        {
            for (int i = 0; i < count; i++)
            {
                Node node = new Node(
                    TestItem.PublicKeys[i],
                    IPAddress.Broadcast.ToString(),
                    30000);

                nodeBucket.AddNode(node);
            }
        }
Пример #4
0
    public NodeAddResult AddNode(Node node)
    {
        CheckInitialization();

        if (_logger.IsTrace)
        {
            _logger.Trace($"Adding node to NodeTable: {node}");
        }
        int        distanceFromMaster = _nodeDistanceCalculator.CalculateDistance(MasterNode !.IdHash.Bytes, node.IdHash.Bytes);
        NodeBucket bucket             = Buckets[distanceFromMaster > 0 ? distanceFromMaster - 1 : 0];

        return(bucket.AddNode(node));
    }