Documentation ¶
Index ¶
Constants ¶
const ( Nanosecond int64 = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Millisecond )
Time duration constants.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func Int64ToTime ¶
int64ToTime creates a UNIX time in million second precision by the given nano seconds.
Types ¶
type MedianTimeSource ¶
type MedianTimeSource interface { // AdjustedTime returns the current time adjusted by the median time // offset as calculated from the time samples added by AddTimeSample. AdjustedTime() time.Time // AddTimeSample adds a time sample that is used when determining the // median time of the added samples. AddTimeSample(id string, timeVal time.Time) // Offset returns the number of nano seconds to adjust the local clock // based upon the median of the time samples added by AddTimeData. Offset() time.Duration }
MedianTimeSource provides a mechanism to add several time samples which are used to determine a median time which is then used as an offset to the local clock.
func NewMedianTime ¶
func NewMedianTime() MedianTimeSource
NewMedianTime returns a new instance of concurrency-safe implementation of the MedianTimeSource interface. The returned implementation contains the rules necessary for proper time handling in the chain consensus rules and expects the time samples to be added from the timestamp field of the version message received from remote peers that successfully connect and negotiate.