Skip to content

Commit

Permalink
raft/tracker: remove unused Inflights.FreeFirstOne
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
pav-kv committed Oct 31, 2022
1 parent ea5ee51 commit 7680b2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
4 changes: 0 additions & 4 deletions raft/tracker/inflights.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ func (in *Inflights) FreeLE(to uint64) {
}
}

// FreeFirstOne releases the first inflight. This is a no-op if nothing is
// inflight.
func (in *Inflights) FreeFirstOne() { in.FreeLE(in.buffer[in.start]) }

// Full returns true if no more messages can be sent at the moment.
func (in *Inflights) Full() bool {
return in.count == in.size
Expand Down
35 changes: 14 additions & 21 deletions raft/tracker/inflights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ func TestInflightFreeTo(t *testing.T) {
in.Add(uint64(i))
}

in.FreeLE(0)

wantIn0 := &Inflights{
start: 1,
count: 9,
size: 10,
// ↓------------------------
buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
}

if !reflect.DeepEqual(in, wantIn0) {
t.Fatalf("in = %+v, want %+v", in, wantIn0)
}

in.FreeLE(4)

wantIn := &Inflights{
Expand Down Expand Up @@ -166,24 +180,3 @@ func TestInflightFreeTo(t *testing.T) {
t.Fatalf("in = %+v, want %+v", in, wantIn4)
}
}

func TestInflightFreeFirstOne(t *testing.T) {
in := NewInflights(10)
for i := 0; i < 10; i++ {
in.Add(uint64(i))
}

in.FreeFirstOne()

wantIn := &Inflights{
start: 1,
count: 9,
size: 10,
// ↓------------------------
buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
}

if !reflect.DeepEqual(in, wantIn) {
t.Fatalf("in = %+v, want %+v", in, wantIn)
}
}

0 comments on commit 7680b2a

Please sign in to comment.