Browse Source

raft: remove unneeded fields

Blake Mizerany 11 years ago
parent
commit
3823b74208
1 changed files with 11 additions and 20 deletions
  1. 11 20
      raft2/raft.go

+ 11 - 20
raft2/raft.go

@@ -68,16 +68,15 @@ func (st stateType) String() string {
 var EmptyState = State{}
 var EmptyState = State{}
 
 
 type Message struct {
 type Message struct {
-	Type      messageType
-	ClusterId int64
-	To        int64
-	From      int64
-	Term      int64
-	LogTerm   int64
-	Index     int64
-	Entries   []Entry
-	Commit    int64
-	Snapshot  Snapshot
+	Type     messageType
+	To       int64
+	From     int64
+	Term     int64
+	LogTerm  int64
+	Index    int64
+	Entries  []Entry
+	Commit   int64
+	Snapshot Snapshot
 }
 }
 
 
 func (m Message) IsMsgApp() bool {
 func (m Message) IsMsgApp() bool {
@@ -129,14 +128,7 @@ func (p int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
 type raft struct {
 type raft struct {
 	State
 	State
 
 
-	// --- new stuff ---
-	name      string
-	election  int
-	heartbeat int
-	// -----------------
-
-	clusterId int64
-	id        int64
+	id int64
 
 
 	// the term we are participating in at any time
 	// the term we are participating in at any time
 	index atomicInt
 	index atomicInt
@@ -170,7 +162,7 @@ func newStateMachine(id int64, peers []int64) *raft {
 	if id == none {
 	if id == none {
 		panic("cannot use none id")
 		panic("cannot use none id")
 	}
 	}
-	sm := &raft{id: id, clusterId: none, lead: none, raftLog: newLog(), ins: make(map[int64]*index)}
+	sm := &raft{id: id, lead: none, raftLog: newLog(), ins: make(map[int64]*index)}
 	for _, p := range peers {
 	for _, p := range peers {
 		sm.ins[p] = &index{}
 		sm.ins[p] = &index{}
 	}
 	}
@@ -211,7 +203,6 @@ func (sm *raft) poll(id int64, v bool) (granted int) {
 
 
 // send persists state to stable storage and then sends to its mailbox.
 // send persists state to stable storage and then sends to its mailbox.
 func (sm *raft) send(m Message) {
 func (sm *raft) send(m Message) {
-	m.ClusterId = sm.clusterId
 	m.From = sm.id
 	m.From = sm.id
 	m.Term = sm.Term
 	m.Term = sm.Term
 	sm.msgs = append(sm.msgs, m)
 	sm.msgs = append(sm.msgs, m)