Browse Source

raft: remove old pointer

Blake Mizerany 11 years ago
parent
commit
1d40440830
1 changed files with 3 additions and 4 deletions
  1. 3 4
      raft2/example_test.go

+ 3 - 4
raft2/example_test.go

@@ -17,7 +17,7 @@ func Example_Node() {
 	// stuff to n happens in other goroutines
 	// stuff to n happens in other goroutines
 
 
 	// the last known state
 	// the last known state
-	var prev *State
+	var prev State
 	for {
 	for {
 		// ReadState blocks until there is new state ready.
 		// ReadState blocks until there is new state ready.
 		st, ents, cents, msgs, err := n.ReadState(context.Background())
 		st, ents, cents, msgs, err := n.ReadState(context.Background())
@@ -25,14 +25,13 @@ func Example_Node() {
 			log.Fatal(err)
 			log.Fatal(err)
 		}
 		}
 
 
-		curr := &st
 		if !prev.Equal(st) {
 		if !prev.Equal(st) {
 			saveStateToDisk(st)
 			saveStateToDisk(st)
-			prev = curr
+			prev = st
 		}
 		}
 
 
 		saveToDisk(ents)
 		saveToDisk(ents)
-		applyToStore(cents)
+		go applyToStore(cents)
 		sendMessages(msgs)
 		sendMessages(msgs)
 	}
 	}
 }
 }