Documentation ¶
Index ¶
- type Peer
- type PeerProducer
- type Timer
- func (self *Timer) ActualTime() time.Time
- func (self *Timer) Conform(peer Peer)
- func (self *Timer) ContinuousTime() (result int64)
- func (self *Timer) Error() (err time.Duration)
- func (self *Timer) Run()
- func (self *Timer) Sample()
- func (self *Timer) Skew(delta time.Duration)
- func (self *Timer) Stability() (result time.Duration)
- func (self *Timer) Start()
- func (self *Timer) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerProducer ¶
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is an abstract time synchronization structure that needs a PeerProducer to provide it with peers from a set of other Timers. It will randomly contact the Peers produced by the PeerProducer to synchronize its time with other peers in the network.
It calculates deviation from _normal_ network latency, and only uses time measurements that respond within standard deviation from the normal response times when adjusting its timer.
func NewTimer ¶
func NewTimer(producer PeerProducer) *Timer
func (*Timer) ActualTime ¶
ActualTime will return what time this Timer thinks it is. It may change forwards or backwards non continuously depending on network interactions.
func (*Timer) Conform ¶
Conform will adjust this Timer to be as exactly as possible that of the provided peer.
func (*Timer) ContinuousTime ¶
ContinuousTime will return a continous nice version of the time this Timer thinks it is. It us guaranteed to never move backwards, and to only move forwards in a smooth fashion.
func (*Timer) Sample ¶
func (self *Timer) Sample()
Sample will make this Timer sample a random Peer produced by the PeerProducer, and Skew according to the delta with the time of that Peer.
func (*Timer) Skew ¶
Skew will change the actual time of this timer with delta, adjusting the continuous time in a smooth fashion.