MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GetNode

Method GetNode

consistent/consistent.go:246–257  ·  view source on GitHub ↗

GetNode returns an node by its node id.

(name string)

Source from the content-addressed store, hash-verified

244
245// GetNode returns an node by its node id.
246func (c *Consistent) GetNode(name string) (*proto.Node, error) {
247 c.RLock()
248 defer c.RUnlock()
249 c.cacheLock.RLock()
250 defer c.cacheLock.RUnlock()
251
252 n, ok := c.circle[hashKey(c.nodeKey(proto.NodeID(name), 0))]
253 if ok {
254 return n, nil
255 }
256 return nil, ErrKeyNotFound
257}
258
259func (c *Consistent) search(key proto.NodeKey) (i int) {
260 f := func(x int) bool {

Callers 2

TestConsistent_GetNodeFunction · 0.80
FindNodeMethod · 0.80

Calls 3

nodeKeyMethod · 0.95
NodeIDTypeAlias · 0.92
hashKeyFunction · 0.85

Tested by 1

TestConsistent_GetNodeFunction · 0.64