lamport: match wikipedia algorithm

This commit is contained in:
Michael Muré 2020-11-08 17:53:11 +01:00
parent 956f98b676
commit 44d7587940
No known key found for this signature in database
GPG Key ID: A4457C029293126F
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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