MCPcopy
hub / github.com/hyperledger/fabric / BlockHeaderBytes

Function BlockHeaderBytes

protoutil/blockutils.go:48–62  ·  view source on GitHub ↗
(b *cb.BlockHeader)

Source from the content-addressed store, hash-verified

46}
47
48func 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
64func BlockHeaderHash(b *cb.BlockHeader) []byte {
65 sum := sha256.Sum256(BlockHeaderBytes(b))

Callers 14

createPrePrepareRequestFunction · 0.92
config_test.goFile · 0.92
TestNewBlockFunction · 0.92
TestGoodBlockHeaderBytesFunction · 0.92
mockBlockFunction · 0.92
mockBlockBFTFunction · 0.92
addBlockSignatureMethod · 0.92
proposalFromRequestsFunction · 0.92
SignProposalMethod · 0.92
AssembleProposalMethod · 0.92
BlockToDecisionMethod · 0.92

Calls 1

MarshalMethod · 0.65

Tested by 6

createPrePrepareRequestFunction · 0.74
TestNewBlockFunction · 0.74
TestGoodBlockHeaderBytesFunction · 0.74
mockBlockFunction · 0.74
mockBlockBFTFunction · 0.74
proposalFromRequestsFunction · 0.74