@@ -140,10 +140,9 @@ func (blockProp *Reactor) requestFromPeer(ps *PeerState) {
140
140
}
141
141
142
142
var (
143
- wants * proptypes.WantParts
144
- parts * proptypes.CombinedPartSet
145
- missingPartsCount int32
146
- fullReqs * bits.BitArray
143
+ wants * proptypes.WantParts
144
+ parts * proptypes.CombinedPartSet
145
+ fullReqs * bits.BitArray
147
146
)
148
147
for i := min (canSend , int64 (len (ps .receivedHaves ))); i > 0 ; {
149
148
if len (ps .receivedHaves ) == 0 {
@@ -159,7 +158,6 @@ func (blockProp *Reactor) requestFromPeer(ps *PeerState) {
159
158
// haves for a new height, resetting
160
159
wants = nil
161
160
parts = nil
162
- missingPartsCount = 0
163
161
}
164
162
165
163
if ! blockProp .relevantHave (have .height , have .round ) {
@@ -173,7 +171,12 @@ func (blockProp *Reactor) requestFromPeer(ps *PeerState) {
173
171
blockProp .Logger .Error ("couldn't find proposal when filtering requests" , "height" , have .height , "round" , have .round )
174
172
break
175
173
}
176
- missingPartsCount = countRemainingParts (int (parts .Total ()), len (parts .BitArray ().GetTrueIndices ()))
174
+ }
175
+
176
+ missingPartsCount := countRemainingParts (int (parts .Total ()), len (parts .BitArray ().GetTrueIndices ()))
177
+ if missingPartsCount == 0 {
178
+ // we can ignore this have in this case
179
+ continue
177
180
}
178
181
179
182
// don't request a part that is already downloaded
@@ -205,10 +208,9 @@ func (blockProp *Reactor) requestFromPeer(ps *PeerState) {
205
208
206
209
if wants == nil {
207
210
wants = & proptypes.WantParts {
208
- Height : have .height ,
209
- Round : have .round ,
210
- Parts : bits .NewBitArray (int (parts .Total ())),
211
- MissingPartsCount : missingPartsCount ,
211
+ Height : have .height ,
212
+ Round : have .round ,
213
+ Parts : bits .NewBitArray (int (parts .Total ())),
212
214
}
213
215
}
214
216
@@ -221,6 +223,12 @@ func (blockProp *Reactor) requestFromPeer(ps *PeerState) {
221
223
if wants == nil {
222
224
continue
223
225
}
226
+ missingPartsCount := countRemainingParts (int (parts .Total ()), len (parts .BitArray ().GetTrueIndices ()))
227
+ if missingPartsCount == 0 {
228
+ // no need to send the want in this case
229
+ continue
230
+ }
231
+ wants .MissingPartsCount = missingPartsCount
224
232
225
233
err := blockProp .sendWantsThenBroadcastHaves (ps , wants )
226
234
if err != nil {
0 commit comments