示例#1
0
        public NodeAddResult AddNode(Node node)
        {
            _logger.Info($"Adding node to NodeTable: {node}");
            var distanceFromMaster = _nodeDistanceCalculator.CalculateDistance(MasterNode.IdHash.Bytes, node.IdHash.Bytes);
            var bucket             = Buckets[distanceFromMaster > 0 ? distanceFromMaster - 1 : 0];

            _nodes.AddOrUpdate(node.IdHashText, node, (x, y) => y);
            return(bucket.AddNode(node));
        }
示例#2
0
        public NodeAddResult AddNode(Node node)
        {
            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];

            _nodes.AddOrUpdate(node.IdHash, node, (x, y) => node);
            return(bucket.AddNode(node));
        }
示例#3
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));
        }