Skip to content

Commit

Permalink
fix incorrect timestamp in uuid v6
Browse files Browse the repository at this point in the history
  • Loading branch information
ls4154 committed Jun 1, 2024
1 parent 6e10cd1 commit e7b44be
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions version6.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ func NewV6() (UUID, error) {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

binary.BigEndian.PutUint64(uuid[0:], uint64(now))
timeHigh := uint32((now >> 28) & 0xffffffff)
timeMid := uint16((now >> 12) & 0xffff)
timeLow := uint16(now & 0x0fff)
timeLow |= 0x6000 // Version 6

binary.BigEndian.PutUint32(uuid[0:], timeHigh)
binary.BigEndian.PutUint16(uuid[4:], timeMid)
binary.BigEndian.PutUint16(uuid[6:], timeLow)
binary.BigEndian.PutUint16(uuid[8:], seq)

uuid[6] = 0x60 | (uuid[6] & 0x0F)
uuid[8] = 0x80 | (uuid[8] & 0x3F)

nodeMu.Lock()
if nodeID == zeroID {
setNodeInterface("")
Expand Down

0 comments on commit e7b44be

Please sign in to comment.