mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-818] Remove time adjustment * [NOD-818] Remove interface ensuring and copyright message * [NOD-818] Update comment
26 lines
571 B
Go
26 lines
571 B
Go
package blockdag
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// TimeSource is the interface to access time.
|
|
type TimeSource interface {
|
|
// Now returns the current time.
|
|
Now() time.Time
|
|
}
|
|
|
|
// timeSource provides an implementation of the TimeSource interface
|
|
// that simply returns the current local time.
|
|
type timeSource struct{}
|
|
|
|
// Now returns the current local time, with one second precision.
|
|
func (m *timeSource) Now() time.Time {
|
|
return time.Unix(time.Now().Unix(), 0)
|
|
}
|
|
|
|
// NewTimeSource returns a new instance of a TimeSource
|
|
func NewTimeSource() TimeSource {
|
|
return &timeSource{}
|
|
}
|