Skip to content

Commit

Permalink
raft: delete unused Ready.containsUpdates method
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
nvanbenschoten committed Oct 25, 2022
1 parent 498aa12 commit 561496a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
6 changes: 0 additions & 6 deletions raft/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ func IsEmptySnap(sp pb.Snapshot) bool {
return sp.Metadata.Index == 0
}

func (rd Ready) containsUpdates() bool {
return rd.SoftState != nil || !IsEmptyHardState(rd.HardState) ||
!IsEmptySnap(rd.Snapshot) || len(rd.Entries) > 0 ||
len(rd.CommittedEntries) > 0 || len(rd.Messages) > 0 || len(rd.ReadStates) != 0
}

// appliedCursor extracts from the Ready the highest index the client has
// applied (once the Ready is confirmed via Advance). If no information is
// contained in the Ready, returns zero.
Expand Down
21 changes: 0 additions & 21 deletions raft/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,27 +530,6 @@ func TestNodeStop(t *testing.T) {
n.Stop()
}

func TestReadyContainUpdates(t *testing.T) {
tests := []struct {
rd Ready
wcontain bool
}{
{Ready{}, false},
{Ready{SoftState: &SoftState{Lead: 1}}, true},
{Ready{HardState: raftpb.HardState{Vote: 1}}, true},
{Ready{Entries: make([]raftpb.Entry, 1)}, true},
{Ready{CommittedEntries: make([]raftpb.Entry, 1)}, true},
{Ready{Messages: make([]raftpb.Message, 1)}, true},
{Ready{Snapshot: raftpb.Snapshot{Metadata: raftpb.SnapshotMetadata{Index: 1}}}, true},
}

for i, tt := range tests {
if g := tt.rd.containsUpdates(); g != tt.wcontain {
t.Errorf("#%d: containUpdates = %v, want %v", i, g, tt.wcontain)
}
}
}

// TestNodeStart ensures that a node can be started correctly. The node should
// start with correct configuration change entries, and can accept and commit
// proposals.
Expand Down
1 change: 0 additions & 1 deletion raft/rawnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func (rn *RawNode) acceptReady(rd Ready) {
}

// HasReady called when RawNode user need to check if any Ready pending.
// Checking logic in this method should be consistent with Ready.containsUpdates().
func (rn *RawNode) HasReady() bool {
r := rn.raft
if !r.softState().equal(rn.prevSoftSt) {
Expand Down

0 comments on commit 561496a

Please sign in to comment.