Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
3d72d8c3
Commit
3d72d8c3
authored
Oct 11, 2022
by
David Stainton
Browse files
Options
Downloads
Patches
Plain Diff
Add obligatory comments as per review
parent
8cb463f9
No related branches found
No related tags found
4 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!404
Add rough draft timeTracker
,
!340
Project/channels
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmix/timeTracker/timeTracker.go
+5
-0
5 additions, 0 deletions
cmix/timeTracker/timeTracker.go
with
5 additions
and
0 deletions
cmix/timeTracker/timeTracker.go
+
5
−
0
View file @
3d72d8c3
...
@@ -27,6 +27,8 @@ type TimeOffsetTracker interface {
...
@@ -27,6 +27,8 @@ type TimeOffsetTracker interface {
Aggregate
()
time
.
Duration
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
{
type
gatewayDelays
struct
{
lock
sync
.
RWMutex
lock
sync
.
RWMutex
delays
[]
*
time
.
Duration
delays
[]
*
time
.
Duration
...
@@ -57,6 +59,7 @@ func (g *gatewayDelays) Average() time.Duration {
...
@@ -57,6 +59,7 @@ func (g *gatewayDelays) Average() time.Duration {
return
average
(
g
.
delays
)
return
average
(
g
.
delays
)
}
}
// timeOffsetTracker implements the TimeOffsetTracker
type
timeOffsetTracker
struct
{
type
timeOffsetTracker
struct
{
gatewayClockDelays
*
sync
.
Map
// id.ID -> *gatewayDelays
gatewayClockDelays
*
sync
.
Map
// id.ID -> *gatewayDelays
...
@@ -75,6 +78,7 @@ func New() TimeOffsetTracker {
...
@@ -75,6 +78,7 @@ func New() TimeOffsetTracker {
return
t
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
)
{
func
(
t
*
timeOffsetTracker
)
Add
(
gwID
*
id
.
ID
,
startTime
,
rTs
time
.
Time
,
rtt
,
gwD
time
.
Duration
)
{
delay
:=
rtt
/
2
-
gwD
delay
:=
rtt
/
2
-
gwD
...
@@ -99,6 +103,7 @@ func (t *timeOffsetTracker) addOffset(offset time.Duration) {
...
@@ -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
{
func
(
t
*
timeOffsetTracker
)
Aggregate
()
time
.
Duration
{
t
.
lock
.
RLock
()
t
.
lock
.
RLock
()
defer
t
.
lock
.
RUnlock
()
defer
t
.
lock
.
RUnlock
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment