@@ -75,7 +75,7 @@ type CompactBlock struct {
7575 mtx sync.Mutex
7676 // proofsCache is local storage from generated proofs from the PartsHashes.
7777 // It must not be included in any serialization.
78- proofsCache []* merkle.Proof
78+ proofsCache []merkle.Proof
7979}
8080
8181// SignBytes returns the compact block commitment data that
@@ -192,7 +192,7 @@ func (c *CompactBlock) ToProto() *protoprop.CompactBlock {
192192// thrown if the proofs are generated and the resulting hashes don't match those
193193// in the compact block. This method should be called upon first receiving a
194194// compact block.
195- func (c * CompactBlock ) Proofs () ([]* merkle.Proof , error ) {
195+ func (c * CompactBlock ) Proofs () ([]merkle.Proof , error ) {
196196 c .mtx .Lock ()
197197 defer c .mtx .Unlock ()
198198
@@ -206,11 +206,11 @@ func (c *CompactBlock) Proofs() ([]*merkle.Proof, error) {
206206 return nil , errors .New ("invalid number of partset hashes" )
207207 }
208208
209- c .proofsCache = make ([]* merkle.Proof , 0 , len (c .PartsHashes ))
209+ c .proofsCache = make ([]merkle.Proof , 0 , len (c .PartsHashes ))
210210
211211 root , proofs := merkle .ProofsFromLeafHashes (c .PartsHashes [:total ])
212212 for i := range proofs {
213- c .proofsCache = append (c .proofsCache , & proofs [i ])
213+ c .proofsCache = append (c .proofsCache , proofs [i ])
214214 }
215215
216216 if ! bytes .Equal (root , c .Proposal .BlockID .PartSetHeader .Hash ) {
@@ -219,7 +219,7 @@ func (c *CompactBlock) Proofs() ([]*merkle.Proof, error) {
219219
220220 parityRoot , eproofs := merkle .ProofsFromLeafHashes (c .PartsHashes [total :])
221221 for i := range eproofs {
222- c .proofsCache = append (c .proofsCache , & eproofs [i ])
222+ c .proofsCache = append (c .proofsCache , eproofs [i ])
223223 }
224224
225225 if ! bytes .Equal (c .BpHash , parityRoot ) {
@@ -233,12 +233,12 @@ func (c *CompactBlock) GetProof(i uint32) *merkle.Proof {
233233 c .mtx .Lock ()
234234 defer c .mtx .Unlock ()
235235 if i < uint32 (len (c .proofsCache )) {
236- return c .proofsCache [i ]
236+ return & c .proofsCache [i ]
237237 }
238238 return nil
239239}
240240
241- func (c * CompactBlock ) SetProofCache (proofs []* merkle.Proof ) {
241+ func (c * CompactBlock ) SetProofCache (proofs []merkle.Proof ) {
242242 c .mtx .Lock ()
243243 defer c .mtx .Unlock ()
244244 c .proofsCache = proofs
@@ -449,7 +449,7 @@ type RecoveryPart struct {
449449 Round int32
450450 Index uint32
451451 Data []byte
452- Proof * merkle.Proof
452+ Proof merkle.Proof
453453}
454454
455455func (p * RecoveryPart ) ValidateBasic () error {
@@ -462,14 +462,12 @@ func (p *RecoveryPart) ValidateBasic() error {
462462 if len (p .Data ) == 0 {
463463 return errors .New ("RecoveryPart: Data cannot be nil or empty" )
464464 }
465- if p .Proof != nil {
466- if err := p .Proof .ValidateBasic (); err != nil {
467- return fmt .Errorf ("RecoveryPart: invalid proof: %w" , err )
468- }
469- hash := merkle .LeafHash (p .Data )
470- if ! bytes .Equal (hash , p .Proof .LeafHash ) {
471- return errors .New ("RecoveryPart: invalid proof leaf hash" )
472- }
465+ if err := p .Proof .ValidateBasic (); err != nil {
466+ return fmt .Errorf ("RecoveryPart: invalid proof: %w" , err )
467+ }
468+ hash := merkle .LeafHash (p .Data )
469+ if ! bytes .Equal (hash , p .Proof .LeafHash ) {
470+ return errors .New ("RecoveryPart: invalid proof leaf hash" )
473471 }
474472 return nil
475473}
@@ -487,7 +485,7 @@ func RecoveryPartFromProto(r *protoprop.RecoveryPart) (*RecoveryPart, error) {
487485 Round : r .Round ,
488486 Index : r .Index ,
489487 Data : r .Data ,
490- Proof : & proof ,
488+ Proof : proof ,
491489 }
492490 return rp , rp .ValidateBasic ()
493491}
0 commit comments