lamport: match wikipedia algorithm

Michael Muré created

Change summary

util/lamport/clock_testing.go | 2 +-
util/lamport/mem_clock.go     | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

Detailed changes

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)

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