mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
logtail: add a few new methods to PublicID
These are for use in our internal systems. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
730aa1c89c
commit
e45d51b060
@ -7,6 +7,7 @@ package logtail
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -156,3 +157,21 @@ func fromHexChar(c byte) (byte, bool) {
|
|||||||
|
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (id1 PublicID) Less(id2 PublicID) bool {
|
||||||
|
for i, c1 := range id1[:] {
|
||||||
|
c2 := id2[i]
|
||||||
|
if c1 != c2 {
|
||||||
|
return c1 < c2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false // equal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (id PublicID) IsZero() bool {
|
||||||
|
return id == PublicID{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (id PublicID) Prefix64() uint64 {
|
||||||
|
return binary.BigEndian.Uint64(id[:8])
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user