diff --git a/raft/node.go b/raft/node.go index 74e57dfa6364..08b9f100625e 100644 --- a/raft/node.go +++ b/raft/node.go @@ -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. diff --git a/raft/node_test.go b/raft/node_test.go index 20d52f6858e8..d152bb346b28 100644 --- a/raft/node_test.go +++ b/raft/node_test.go @@ -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. diff --git a/raft/rawnode.go b/raft/rawnode.go index 1e89323bf00f..cfa4c1881174 100644 --- a/raft/rawnode.go +++ b/raft/rawnode.go @@ -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) {