Browse Source

raft: do not load empty state and ents

Xiang Li 11 years ago
parent
commit
dbdeceda7b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      raft/node.go

+ 6 - 2
raft/node.go

@@ -168,8 +168,12 @@ func RestartNode(id uint64, election, heartbeat int, snapshot *pb.Snapshot, st p
 	if snapshot != nil {
 	if snapshot != nil {
 		r.restore(*snapshot)
 		r.restore(*snapshot)
 	}
 	}
-	r.loadState(st)
-	r.loadEnts(ents)
+	if !isHardStateEqual(st, emptyState) {
+		r.loadState(st)
+	}
+	if len(ents) != 0 {
+		r.loadEnts(ents)
+	}
 	go n.run(r)
 	go n.run(r)
 	return &n
 	return &n
 }
 }