2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-08-17 20:11:46 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package kademlia
|
|
|
|
|
|
|
|
import (
|
2018-09-18 05:39:06 +01:00
|
|
|
"storj.io/storj/pkg/pb"
|
2018-08-17 20:11:46 +01:00
|
|
|
)
|
|
|
|
|
2018-11-29 18:39:27 +00:00
|
|
|
func (rt *RoutingTable) addToReplacementCache(kadBucketID bucketID, node *pb.Node) {
|
|
|
|
nodes := rt.replacementCache[kadBucketID]
|
2018-08-17 20:11:46 +01:00
|
|
|
nodes = append(nodes, node)
|
|
|
|
if len(nodes) > rt.rcBucketSize {
|
|
|
|
copy(nodes, nodes[1:])
|
|
|
|
nodes = nodes[:len(nodes)-1]
|
|
|
|
}
|
2018-11-29 18:39:27 +00:00
|
|
|
rt.replacementCache[kadBucketID] = nodes
|
2018-08-17 20:11:46 +01:00
|
|
|
}
|