diff --git a/report/id.go b/report/id.go index 7fb94a0b7..908376f48 100644 --- a/report/id.go +++ b/report/id.go @@ -1,13 +1,8 @@ package report import ( - "hash" - "hash/fnv" "net" "strings" - "sync" - - "github.com/bluele/gcache" ) // TheInternet is used as a node ID to indicate a remote IP. @@ -29,38 +24,9 @@ const ( DoesNotMakeConnections = "does_not_make_connections" ) -var ( - idCache = gcache.New(1024).LRU().Build() - hashers = sync.Pool{ - New: func() interface{} { - return fnv.New64a() - }, - } -) - -func lookupID(part1, part2, part3 string, f func() string) string { - h := hashers.Get().(hash.Hash64) - h.Write([]byte(part1)) - h.Write([]byte(part2)) - h.Write([]byte(part3)) - sum := h.Sum64() - var result string - if id, err := idCache.Get(sum); id != nil && err != nil { - result = id.(string) - } else { - result = f() - idCache.Set(sum, result) - } - h.Reset() - hashers.Put(h) - return result -} - // MakeEndpointNodeID produces an endpoint node ID from its composite parts. func MakeEndpointNodeID(hostID, address, port string) string { - return lookupID(hostID, address, port, func() string { - return MakeAddressNodeID(hostID, address) + ScopeDelim + port - }) + return MakeAddressNodeID(hostID, address) + ScopeDelim + port } // MakeAddressNodeID produces an address node ID from its composite parts.