Skip to content
Snippets Groups Projects
Commit 3d72d8c3 authored by David Stainton's avatar David Stainton
Browse files

Add obligatory comments as per review

parent 8cb463f9
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!404Add rough draft timeTracker,!340Project/channels
......@@ -27,6 +27,8 @@ type TimeOffsetTracker interface {
Aggregate() time.Duration
}
// gatewayDelays is a helper type used by the timeOffsetTracker below
// to keep track of the last maxHistogramSize number of durations.
type gatewayDelays struct {
lock sync.RWMutex
delays []*time.Duration
......@@ -57,6 +59,7 @@ func (g *gatewayDelays) Average() time.Duration {
return average(g.delays)
}
// timeOffsetTracker implements the TimeOffsetTracker
type timeOffsetTracker struct {
gatewayClockDelays *sync.Map // id.ID -> *gatewayDelays
......@@ -75,6 +78,7 @@ func New() TimeOffsetTracker {
return t
}
// Add implements the Add method of the TimeOffsetTracker interface.
func (t *timeOffsetTracker) Add(gwID *id.ID, startTime, rTs time.Time, rtt, gwD time.Duration) {
delay := rtt/2 - gwD
......@@ -99,6 +103,7 @@ func (t *timeOffsetTracker) addOffset(offset time.Duration) {
}
}
// Aggregate implements the Aggregate method fo the TimeOffsetTracker interface.
func (t *timeOffsetTracker) Aggregate() time.Duration {
t.lock.RLock()
defer t.lock.RUnlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment