diff --git a/bindings/timeNow.go b/bindings/timeNow.go new file mode 100644 index 0000000000000000000000000000000000000000..d4ef6929d7e28402f979e6d8530026ea11f4ef34 --- /dev/null +++ b/bindings/timeNow.go @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 xx network SEZC // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file // +/////////////////////////////////////////////////////////////////////////////// + +package bindings + +import ( + "gitlab.com/xx_network/primitives/netTime" + "time" +) + +// SetTimeSource will set the time source that will be used when retrieving the +// current time using [netTime.Now]. +// +// Parameters: +// - timeNow is an object which adheres to [netTime.TimeSource]. Specifically, +// this object should a NowMs() method which return a 64-bit integer value. +func SetTimeSource(timeNow netTime.TimeSource) { + netTime.SetTimeSource(timeNow) +} + +// SetOffset will set an internal offset variable. All calls to [netTime.Now] +// will have this offset applied to this value. +// +// Parameters: +// - offset is a time by which netTime.Now will be offset. This value may be +// negative or positive. This expects a 64-bit integer value which will +// represent the number in microseconds this offset will be. +func SetOffset(offset int64) { + netTime.SetOffset(time.Duration(offset) * time.Microsecond) +} diff --git a/go.mod b/go.mod index 5bb8e838962b73a263217f083138058fcdb87375..372fb69b5f827d9103636d2aaf5d5f42724216a3 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( gitlab.com/elixxir/primitives v0.0.3-0.20220606195757-40f7a589347f gitlab.com/xx_network/comms v0.0.4-0.20220630163702-f3d372ef6acd gitlab.com/xx_network/crypto v0.0.5-0.20220729193517-1e5e96f39f6e - gitlab.com/xx_network/primitives v0.0.4-0.20220712193914-aebd8544396e + gitlab.com/xx_network/primitives v0.0.4-0.20221010192422-3479f09b7769 go.uber.org/ratelimit v0.2.0 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b diff --git a/go.sum b/go.sum index cccd675d6b722e0aaac060aeb9f6d0c0bd2630a2..2e2ecf7e928609c7877100b0f1597c23f6a16bb3 100644 --- a/go.sum +++ b/go.sum @@ -461,6 +461,8 @@ gitlab.com/xx_network/primitives v0.0.4-0.20220324193139-b292d1ae6e7e/go.mod h1: gitlab.com/xx_network/primitives v0.0.4-0.20220630163313-7890038258c6/go.mod h1:AXVVFt7dDAeIUpOGPiStCcUIKsBXLWbmV/BgZ4T+tOo= gitlab.com/xx_network/primitives v0.0.4-0.20220712193914-aebd8544396e h1:zRRo/v3KUo3MtpjNJaB03LR+Zi2g1afYF8yKWl1t19o= gitlab.com/xx_network/primitives v0.0.4-0.20220712193914-aebd8544396e/go.mod h1:AXVVFt7dDAeIUpOGPiStCcUIKsBXLWbmV/BgZ4T+tOo= +gitlab.com/xx_network/primitives v0.0.4-0.20221010192422-3479f09b7769 h1:BBYSog3VSKudey4rhWnCw54PcGcD4YRjTrnwzOhJ/GE= +gitlab.com/xx_network/primitives v0.0.4-0.20221010192422-3479f09b7769/go.mod h1:AXVVFt7dDAeIUpOGPiStCcUIKsBXLWbmV/BgZ4T+tOo= gitlab.com/xx_network/ring v0.0.3-0.20220222211904-da613960ad93 h1:eJZrXqHsMmmejEPWw8gNAt0I8CGAMNO/7C339Zco3TM= gitlab.com/xx_network/ring v0.0.3-0.20220222211904-da613960ad93/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=