aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-11-08 17:53:11 +0100
committerMichael Muré <batolettre@gmail.com>2021-02-14 12:14:34 +0100
commit44d7587940f842a343a64d9107601591bdfb1027 (patch)
tree07362517b293009074dfcd7e1bf8dcba487c2135 /util
parent956f98b676ab44d19ed522061c9520a32aab1a3c (diff)
downloadgit-bug-44d7587940f842a343a64d9107601591bdfb1027.tar.gz
lamport: match wikipedia algorithm
Diffstat (limited to 'util')
-rw-r--r--util/lamport/clock_testing.go2
-rw-r--r--util/lamport/mem_clock.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/util/lamport/clock_testing.go b/util/lamport/clock_testing.go
index fc59afb2..4bf6d2bf 100644
--- a/util/lamport/clock_testing.go
+++ b/util/lamport/clock_testing.go
@@ -11,7 +11,7 @@ func testClock(t *testing.T, c Clock) {
val, err := c.Increment()
assert.NoError(t, err)
- assert.Equal(t, Time(1), val)
+ assert.Equal(t, Time(2), val)
assert.Equal(t, Time(2), c.Time())
err = c.Witness(41)
diff --git a/util/lamport/mem_clock.go b/util/lamport/mem_clock.go
index ce6f2d4d..f113b501 100644
--- a/util/lamport/mem_clock.go
+++ b/util/lamport/mem_clock.go
@@ -62,7 +62,7 @@ func (mc *MemClock) Time() Time {
// Increment is used to return the value of the lamport clock and increment it afterwards
func (mc *MemClock) Increment() (Time, error) {
- return Time(atomic.AddUint64(&mc.counter, 1) - 1), nil
+ return Time(atomic.AddUint64(&mc.counter, 1)), nil
}
// Witness is called to update our local clock if necessary after