Beginning work noise handshake
This commit is contained in:
parent
1868d15914
commit
50aeefcb51
7 changed files with 422 additions and 4 deletions
23
src/tai64.go
Normal file
23
src/tai64.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
TAI64NBase = uint64(4611686018427387914)
|
||||
TAI64NSize = 12
|
||||
)
|
||||
|
||||
type TAI64N [TAI64NSize]byte
|
||||
|
||||
func Timestamp() TAI64N {
|
||||
var tai64n TAI64N
|
||||
now := time.Now()
|
||||
secs := TAI64NBase + uint64(now.Unix())
|
||||
nano := uint32(now.UnixNano())
|
||||
binary.BigEndian.PutUint64(tai64n[:], secs)
|
||||
binary.BigEndian.PutUint32(tai64n[8:], nano)
|
||||
return tai64n
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue