mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: remove unneeded fields
This commit is contained in:
parent
1d40440830
commit
3823b74208
@ -68,16 +68,15 @@ func (st stateType) String() string {
|
|||||||
var EmptyState = State{}
|
var EmptyState = State{}
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Type messageType
|
Type messageType
|
||||||
ClusterId int64
|
To int64
|
||||||
To int64
|
From int64
|
||||||
From int64
|
Term int64
|
||||||
Term int64
|
LogTerm int64
|
||||||
LogTerm int64
|
Index int64
|
||||||
Index int64
|
Entries []Entry
|
||||||
Entries []Entry
|
Commit int64
|
||||||
Commit int64
|
Snapshot Snapshot
|
||||||
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 ---
|
id int64
|
||||||
name string
|
|
||||||
election int
|
|
||||||
heartbeat int
|
|
||||||
// -----------------
|
|
||||||
|
|
||||||
clusterId 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user