@@ -60,12 +60,27 @@ type LeiosBlockHeaderBody struct {
6060 CertifiedEb * bool
6161}
6262
63+ type LeiosEndorserBlockBody struct {
64+ cbor.StructAsArray
65+ Transactions []common.Transaction
66+ TxReferences map [common.Blake2b256 ]uint16
67+ }
68+
69+ func (b * LeiosEndorserBlockBody ) BlockBodyHash () common.Blake2b256 {
70+ // Compute hash of the block body content
71+ bodyCbor , err := cbor .Encode (b )
72+ if err != nil {
73+ // Return zero hash on encoding error
74+ return common.Blake2b256 {}
75+ }
76+ return common .Blake2b256Hash (bodyCbor )
77+ }
78+
6379type LeiosEndorserBlock struct {
6480 cbor.DecodeStoreCbor
6581 cbor.StructAsArray
66- hash * common.Blake2b256
67- transactions []common.Transaction
68- TxReferences map [common.Blake2b256 ]uint16
82+ hash * common.Blake2b256
83+ Body * LeiosEndorserBlockBody
6984}
7085
7186func (h * LeiosBlockHeader ) UnmarshalCBOR (cborData []byte ) error {
@@ -111,6 +126,10 @@ func (h *LeiosBlockHeader) Era() common.Era {
111126 return EraLeios
112127}
113128
129+ func (h * LeiosBlockHeader ) BlockBodyHash () common.Blake2b256 {
130+ return h .Body .BlockBodyHash
131+ }
132+
114133func (LeiosEndorserBlock ) Type () int {
115134 return BlockTypeLeiosEndorser
116135}
@@ -154,14 +173,24 @@ func (b *LeiosEndorserBlock) PrevHash() common.Blake2b256 {
154173}
155174
156175func (b * LeiosEndorserBlock ) Transactions () []common.Transaction {
157- return b .transactions
176+ if b .Body == nil {
177+ return nil
178+ }
179+ return b .Body .Transactions
158180}
159181
160182func (b * LeiosEndorserBlock ) Utxorpc () (* utxorpc.Block , error ) {
161183 // TODO: figure out how this fits into UTxO RPC
162184 return & utxorpc.Block {}, nil
163185}
164186
187+ func (b * LeiosEndorserBlock ) BlockBodyHash () common.Blake2b256 {
188+ if b .Body == nil {
189+ return common.Blake2b256 {}
190+ }
191+ return b .Body .BlockBodyHash ()
192+ }
193+
165194type LeiosRankingBlock struct {
166195 conway.ConwayBlock
167196 BlockHeader * LeiosBlockHeader `cbor:"0,keyasint"`
@@ -248,6 +277,10 @@ func (b *LeiosRankingBlock) Utxorpc() (*utxorpc.Block, error) {
248277 return block , nil
249278}
250279
280+ func (b * LeiosRankingBlock ) BlockBodyHash () common.Blake2b256 {
281+ return b .Header ().BlockBodyHash ()
282+ }
283+
251284func NewLeiosEndorserBlockFromCbor (data []byte ) (* LeiosEndorserBlock , error ) {
252285 var leiosEndorserBlock LeiosEndorserBlock
253286 if _ , err := cbor .Decode (data , & leiosEndorserBlock ); err != nil {
0 commit comments