export key -> id conversion
This commit is contained in:
parent
9c49d89637
commit
d5f26bb2bf
@ -16,10 +16,11 @@ func addrID(addr netip.AddrPort) ID {
|
||||
}
|
||||
b := make([]byte, 0, len("[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0]:65535"))
|
||||
b = addr.AppendTo(b)
|
||||
return keyID(b)
|
||||
return Key(b)
|
||||
}
|
||||
|
||||
func keyID[T string | []byte](key T) ID {
|
||||
// Key obtains the ID for an arbitrary key.
|
||||
func Key[T string | []byte](key T) ID {
|
||||
s := sha1.Sum([]byte(key))
|
||||
return s
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user