MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / MarshalHash

Method MarshalHash

types/block_gen.go:10–64  ·  view source on GitHub ↗

MarshalHash marshals for hash

()

Source from the content-addressed store, hash-verified

8
9// MarshalHash marshals for hash
10func (z *Block) MarshalHash() (o []byte, err error) {
11 var b []byte
12 o = hsp.Require(b, z.Msgsize())
13 // map header, size 4
14 o = append(o, 0x84)
15 o = hsp.AppendArrayHeader(o, uint32(len(z.Acks)))
16 for za0003 := range z.Acks {
17 if z.Acks[za0003] == nil {
18 o = hsp.AppendNil(o)
19 } else {
20 if oTemp, err := z.Acks[za0003].MarshalHash(); err != nil {
21 return nil, err
22 } else {
23 o = hsp.AppendBytes(o, oTemp)
24 }
25 }
26 }
27 o = hsp.AppendArrayHeader(o, uint32(len(z.FailedReqs)))
28 for za0001 := range z.FailedReqs {
29 if z.FailedReqs[za0001] == nil {
30 o = hsp.AppendNil(o)
31 } else {
32 if oTemp, err := z.FailedReqs[za0001].MarshalHash(); err != nil {
33 return nil, err
34 } else {
35 o = hsp.AppendBytes(o, oTemp)
36 }
37 }
38 }
39 o = hsp.AppendArrayHeader(o, uint32(len(z.QueryTxs)))
40 for za0002 := range z.QueryTxs {
41 if z.QueryTxs[za0002] == nil {
42 o = hsp.AppendNil(o)
43 } else {
44 if oTemp, err := z.QueryTxs[za0002].MarshalHash(); err != nil {
45 return nil, err
46 } else {
47 o = hsp.AppendBytes(o, oTemp)
48 }
49 }
50 }
51 // map header, size 2
52 o = append(o, 0x82)
53 if oTemp, err := z.SignedHeader.Header.MarshalHash(); err != nil {
54 return nil, err
55 } else {
56 o = hsp.AppendBytes(o, oTemp)
57 }
58 if oTemp, err := z.SignedHeader.HSV.MarshalHash(); err != nil {
59 return nil, err
60 } else {
61 o = hsp.AppendBytes(o, oTemp)
62 }
63 return
64}
65
66// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
67func (z *Block) Msgsize() (s int) {

Callers 4

TestMarshalHashBlockFunction · 0.95
BenchmarkAppendMsgBlockFunction · 0.95

Calls 2

MsgsizeMethod · 0.95
MarshalHashMethod · 0.65

Tested by 4

TestMarshalHashBlockFunction · 0.76
BenchmarkAppendMsgBlockFunction · 0.76