Skip to content

Commit

Permalink
Updated the MarshalBlock method to follow the workobject struct
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Sep 5, 2024
1 parent f55c310 commit e0c2151
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/quaiapi/quai_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,10 @@ func RPCMarshalBlock(backend Backend, block *types.WorkObject, inclTx bool, full

fields["hash"] = block.Hash()
fields["woHeader"] = block.WorkObjectHeader().RPCMarshalWorkObjectHeader()
fields["header"] = block.Body().Header().RPCMarshalHeader()
fields["size"] = hexutil.Uint64(block.Size())

body := make(map[string]interface{})
body["header"] = block.Body().Header().RPCMarshalHeader()
if inclTx {
formatTx := func(tx *types.Transaction) (interface{}, error) {
return tx.Hash(), nil
Expand All @@ -589,15 +590,15 @@ func RPCMarshalBlock(backend Backend, block *types.WorkObject, inclTx bool, full
return nil, err
}
}
fields["transactions"] = transactions
body["transactions"] = transactions
etxs := block.Etxs()
formatEtxs := make([]interface{}, len(etxs))
for i, etx := range etxs {
if formatEtxs[i], err = formatEtx(etx); err != nil {
return nil, err
}
}
fields["etxs"] = formatEtxs
body["etxs"] = formatEtxs
}

var marshalUncles []map[string]interface{}
Expand All @@ -611,11 +612,12 @@ func RPCMarshalBlock(backend Backend, block *types.WorkObject, inclTx bool, full
marshalUncles = append(marshalUncles, rpcMarshalUncle)
}
}
fields["uncles"] = marshalUncles
fields["workshares"] = marshalWorkShares
fields["subManifest"] = block.Manifest()
fields["interlinkHashes"] = block.InterlinkHashes()
body["uncles"] = marshalUncles
body["workshares"] = marshalWorkShares
body["subManifest"] = block.Manifest()
body["interlinkHashes"] = block.InterlinkHashes()

fields["woBody"] = body
return fields, nil
}

Expand Down

0 comments on commit e0c2151

Please sign in to comment.