| 46 | } |
| 47 | |
| 48 | func BlockHeaderBytes(b *cb.BlockHeader) []byte { |
| 49 | asn1Header := asn1Header{ |
| 50 | PreviousHash: b.PreviousHash, |
| 51 | DataHash: b.DataHash, |
| 52 | Number: new(big.Int).SetUint64(b.Number), |
| 53 | } |
| 54 | result, err := asn1.Marshal(asn1Header) |
| 55 | if err != nil { |
| 56 | // Errors should only arise for types which cannot be encoded, since the |
| 57 | // BlockHeader type is known a-priori to contain only encodable types, an |
| 58 | // error here is fatal and should not be propagated |
| 59 | panic(err) |
| 60 | } |
| 61 | return result |
| 62 | } |
| 63 | |
| 64 | func BlockHeaderHash(b *cb.BlockHeader) []byte { |
| 65 | sum := sha256.Sum256(BlockHeaderBytes(b)) |