@@ -57,7 +57,7 @@ type SBFT struct {
57
57
58
58
config Config
59
59
id uint64
60
- seq SeqView
60
+ view uint64
61
61
batch []* Request
62
62
batchTimer Canceller
63
63
cur reqInfo
@@ -109,26 +109,17 @@ func New(id uint64, config *Config, sys System) (*SBFT, error) {
109
109
}
110
110
s .sys .SetReceiver (s )
111
111
112
- lastBatch := s .sys .LastBatch ()
113
- bh , err := s .checkBatch (lastBatch , false )
114
- if err != nil {
115
- panic (err )
116
- }
117
-
118
- s .seq .View = 0
119
- s .seq .Seq = bh .Seq
120
- s .cur .subject .Seq = & s .seq
112
+ s .view = 0
113
+ s .cur .subject .Seq = & SeqView {}
121
114
s .cur .sentCommit = true
122
115
s .cur .executed = true
123
116
s .cur .checkpointDone = true
124
117
s .cur .timeout = dummyCanceller {}
125
118
126
119
pp := & Preprepare {}
127
120
if s .sys .Restore ("preprepare" , pp ) {
128
- s .seq .View = pp .Seq .View
129
- if pp .Seq .Seq > bh .Seq {
130
- s .seq = * pp .Seq
131
- s .seq .Seq -= 1
121
+ s .view = pp .Seq .View
122
+ if pp .Seq .Seq > s .seq () {
132
123
s .acceptPreprepare (pp )
133
124
}
134
125
}
@@ -141,7 +132,7 @@ func New(id uint64, config *Config, sys System) (*SBFT, error) {
141
132
s .cur .executed = true
142
133
}
143
134
144
- if s .seq . Seq == 0 {
135
+ if s .seq () == 0 {
145
136
s .activeView = true
146
137
}
147
138
@@ -156,21 +147,23 @@ func (s *SBFT) primaryIDView(v uint64) uint64 {
156
147
}
157
148
158
149
func (s * SBFT ) primaryID () uint64 {
159
- return s .primaryIDView (s .seq . View )
150
+ return s .primaryIDView (s .view )
160
151
}
161
152
162
153
func (s * SBFT ) isPrimary () bool {
163
154
return s .primaryID () == s .id
164
155
}
165
156
157
+ func (s * SBFT ) seq () uint64 {
158
+ return s .sys .LastBatch ().DecodeHeader ().Seq
159
+ }
160
+
166
161
func (s * SBFT ) nextSeq () SeqView {
167
- seq := s .seq
168
- seq .Seq += 1
169
- return seq
162
+ return SeqView {Seq : s .seq () + 1 , View : s .view }
170
163
}
171
164
172
165
func (s * SBFT ) nextView () uint64 {
173
- return s .seq . View + 1
166
+ return s .view + 1
174
167
}
175
168
176
169
func (s * SBFT ) noFaultyQuorum () int {
0 commit comments