91bf6e19e8
* creating replacement cache * wip * wip * rewrites replacement cache * replacement cache tests * update and remove node tests * check if dropped node got added to replacement cache from add node method * wip * wip * making changes based on pr
22 lines
505 B
Go
22 lines
505 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package kademlia
|
|
|
|
import (
|
|
proto "storj.io/storj/protos/overlay"
|
|
"storj.io/storj/storage"
|
|
)
|
|
|
|
|
|
func (rt *RoutingTable) addToReplacementCache(kadBucketID storage.Key, node *proto.Node) {
|
|
bucketID := string(kadBucketID)
|
|
nodes := rt.replacementCache[bucketID]
|
|
nodes = append(nodes, node)
|
|
if len(nodes) > rt.rcBucketSize {
|
|
copy(nodes, nodes[1:])
|
|
nodes = nodes[:len(nodes)-1]
|
|
}
|
|
rt.replacementCache[bucketID] = nodes
|
|
}
|