示例#1
0
        public RoutTable(KadId self)
        {
            Guard.NotNull(self, nameof(self));

            _buckets = new List <KBucket>();
            _self    = self;
        }
示例#2
0
        public int FindBucket(KadId id)
        {
            int numBukets = _buckets.Count;

            if (numBukets == 0)
            {
                _buckets.Add(new KBucket());
                numBukets++;
            }

            int bucketIndex = Math.Min(KadId.TOTAL_BITS - 1 - KadId.DistanceExp(_self, id), numBukets - 1);

            Guard.Assert(bucketIndex < _buckets.Count);
            Guard.Assert(bucketIndex >= 0);
            return(bucketIndex);
        }