@@ -190,11 +190,13 @@ func (blockProp *Reactor) handleWants(peer p2p.ID, wants *proptypes.WantParts) {
190190
191191 for _ , partIndex := range canSend .GetTrueIndices () {
192192 part , _ := parts .GetPart (uint32 (partIndex ))
193+ partBz := make ([]byte , len (part .Bytes ))
194+ copy (partBz , part .Bytes )
193195 rpart := & propproto.RecoveryPart {
194196 Height : height ,
195197 Round : round ,
196198 Index : uint32 (partIndex ),
197- Data : part . Bytes ,
199+ Data : partBz ,
198200 }
199201 if wants .Prove {
200202 rpart .Proof = part .Proof .ToProto ()
@@ -290,7 +292,13 @@ func (blockProp *Reactor) handleRecoveryPart(peer p2p.ID, part *proptypes.Recove
290292 // during catchup. todo: use the bool found in the state instead of checking
291293 // for nil.
292294 if parts .CanDecode () {
293- err := parts .Decode (blockProp .codec )
295+ if parts .IsDecoding .Load () {
296+ return
297+ }
298+ parts .IsDecoding .Store (true )
299+ defer parts .IsDecoding .Store (false )
300+
301+ err := parts .Decode ()
294302 if err != nil {
295303 blockProp .Logger .Error ("failed to decode parts" , "peer" , peer , "height" , part .Height , "round" , part .Round , "error" , err )
296304 return
@@ -318,11 +326,13 @@ func (blockProp *Reactor) handleRecoveryPart(peer p2p.ID, part *proptypes.Recove
318326 go func (height int64 , round int32 , parts * proptypes.CombinedPartSet ) {
319327 for i := uint32 (0 ); i < parts .Total (); i ++ {
320328 p , _ := parts .GetPart (i )
329+ pbz := make ([]byte , len (p .Bytes ))
330+ copy (pbz , p .Bytes )
321331 msg := & proptypes.RecoveryPart {
322332 Height : height ,
323333 Round : round ,
324334 Index : p .Index ,
325- Data : p . Bytes ,
335+ Data : pbz ,
326336 }
327337 blockProp .clearWants (msg )
328338 }
0 commit comments