@@ -78,7 +78,13 @@ func (s *SBFT) handlePreprepare(pp *Preprepare, src uint64) {
78
78
log .Infof ("replica %d: preprepare batches prev hash does not match expected %s, got %s" , s .id , hash2str (batchheader .PrevHash ), hash2str (prevhash ))
79
79
return
80
80
}
81
- committers := s .getCommitters (pp )
81
+
82
+ blockOK , committers := s .getCommittersFromBatch (pp .Batch )
83
+ if ! blockOK {
84
+ log .Debugf ("Replica %d found Byzantine block in preprepare, Seq: %d View: %d" , s .id , pp .Seq .Seq , pp .Seq .View )
85
+ s .sendViewChange ()
86
+ return
87
+ }
82
88
log .Infof ("replica %d: handlePrepare" , s .id )
83
89
s .handleCheckedPreprepare (pp , committers )
84
90
}
@@ -100,26 +106,6 @@ func (s *SBFT) acceptPreprepare(pp *Preprepare, committers []filter.Committer) {
100
106
}
101
107
}
102
108
103
- func (s * SBFT ) getCommitters (pp * Preprepare ) []filter.Committer {
104
- // if we are the primary, we can be sure the block is OK
105
- // and we also have the committers
106
- // TODO what to do with the remaining ones???
107
- // how to mantain the mapping between batches and committers?
108
- var committers []filter.Committer
109
-
110
- if ! s .isPrimary () {
111
- blockOK , allcommitters := s .getCommittersFromBlockCutter (pp .Batch )
112
- if ! blockOK {
113
- log .Panicf ("Replica %d found Byzantine block, Seq: %d View: %d" , s .id , pp .Seq .Seq , pp .Seq .View )
114
- }
115
- committers = allcommitters
116
- } else {
117
- committers = s .primarycommitters [0 ]
118
- s .primarycommitters = s .primarycommitters [1 :]
119
- }
120
- return committers
121
- }
122
-
123
109
func (s * SBFT ) handleCheckedPreprepare (pp * Preprepare , committers []filter.Committer ) {
124
110
s .acceptPreprepare (pp , committers )
125
111
if ! s .isPrimary () {
@@ -130,34 +116,6 @@ func (s *SBFT) handleCheckedPreprepare(pp *Preprepare, committers []filter.Commi
130
116
s .maybeSendCommit ()
131
117
}
132
118
133
- func (s * SBFT ) getCommittersFromBlockCutter (reqBatch * Batch ) (bool , []filter.Committer ) {
134
- reqs := make ([]* Request , 0 , len (reqBatch .Payloads ))
135
- for _ , pl := range reqBatch .Payloads {
136
- req := & Request {Payload : pl }
137
- reqs = append (reqs , req )
138
- }
139
- batches := make ([][]* Request , 0 , 1 )
140
- comms := [][]filter.Committer {}
141
- for _ , r := range reqs {
142
- b , c , accepted := s .sys .Ordered (s .chainId , r )
143
- if ! accepted {
144
- return false , nil
145
- }
146
- batches = append (batches , b ... )
147
- comms = append (comms , c ... )
148
- }
149
- if len (batches ) > 1 || len (batches ) != len (comms ) {
150
- return false , nil
151
- }
152
-
153
- if len (batches ) == 0 {
154
- _ , committer := s .sys .Cut (s .chainId )
155
- return true , committer
156
- } else {
157
- return true , comms [0 ]
158
- }
159
- }
160
-
161
119
////////////////////////////////////////////////
162
120
163
121
func (s * SBFT ) requestTimeout () {
0 commit comments