MCPcopy Create free account
hub / github.com/encodeous/nylon / lookup

Method lookup

polyamide/device/allowedips.go:191–205  ·  view source on GitHub ↗
(ip []byte)

Source from the content-addressed store, hash-verified

189}
190
191func (node *trieEntry) lookup(ip []byte) *Peer {
192 var found *Peer
193 size := uint8(len(ip))
194 for node != nil && commonBits(node.bits, ip) >= node.cidr {
195 if node.peer != nil {
196 found = node.peer
197 }
198 if node.bitAtByte == size {
199 break
200 }
201 bit := node.choose(ip)
202 node = node.child[bit]
203 }
204 return found
205}
206
207type AllowedIPs struct {
208 IPv4 *trieEntry

Callers 2

benchmarkTrieFunction · 0.95
LookupMethod · 0.80

Calls 2

chooseMethod · 0.95
commonBitsFunction · 0.85

Tested by 1

benchmarkTrieFunction · 0.76