fix BlockHeader object of json-rpc
- add missing baseFeePerGas field - add missing mixHash field
This commit is contained in:
parent
89fd986a00
commit
727a3ee7b1
|
@ -62,10 +62,12 @@ type
|
|||
difficulty*: HexQuantityStr # integer of the difficulty for this block.
|
||||
totalDifficulty*: HexQuantityStr# integer of the total difficulty of the chain until this block.
|
||||
extraData*: HexDataStr # the "extra data" field of this block.
|
||||
mixHash*: Hash256
|
||||
size*: HexQuantityStr # integer the size of this block in bytes.
|
||||
gasLimit*: HexQuantityStr # the maximum gas allowed in this block.
|
||||
gasUsed*: HexQuantityStr # the total used gas by all transactions in this block.
|
||||
timestamp*: HexQuantityStr # the unix timestamp for when the block was collated.
|
||||
baseFeePerGas*: Option[HexQuantityStr]
|
||||
transactions*: seq[JsonNode] # list of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
|
||||
uncles*: seq[Hash256] # list of uncle hashes.
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ template optionalU256(src, dst: untyped) =
|
|||
template optionalBytes(src, dst: untyped) =
|
||||
if src.isSome:
|
||||
dst = hexToSeqByte(src.get.string)
|
||||
|
||||
proc callData*(call: EthCall): RpcCallData =
|
||||
|
||||
proc callData*(call: EthCall): RpcCallData =
|
||||
optionalAddress(call.source, result.source)
|
||||
optionalAddress(call.to, result.to)
|
||||
optionalGas(call.gas, result.gasLimit)
|
||||
|
@ -144,6 +144,7 @@ proc populateBlockObject*(header: BlockHeader, chain: BaseChainDB, fullTx: bool,
|
|||
result.miner = header.coinbase
|
||||
result.difficulty = encodeQuantity(header.difficulty)
|
||||
result.extraData = hexDataStr(header.extraData)
|
||||
result.mixHash = header.mixDigest
|
||||
|
||||
# discard sizeof(seq[byte]) of extraData and use actual length
|
||||
let size = sizeof(BlockHeader) - sizeof(Blob) + header.extraData.len
|
||||
|
@ -152,7 +153,10 @@ proc populateBlockObject*(header: BlockHeader, chain: BaseChainDB, fullTx: bool,
|
|||
result.gasLimit = encodeQuantity(header.gasLimit.uint64)
|
||||
result.gasUsed = encodeQuantity(header.gasUsed.uint64)
|
||||
result.timestamp = encodeQuantity(header.timeStamp.toUnix.uint64)
|
||||
|
||||
result.baseFeePerGas = if header.fee.isSome:
|
||||
some(encodeQuantity(header.baseFee))
|
||||
else:
|
||||
none(HexQuantityStr)
|
||||
if not isUncle:
|
||||
result.totalDifficulty = encodeQuantity(chain.getScore(blockHash))
|
||||
result.uncles = chain.getUncleHashes(header)
|
||||
|
|
Loading…
Reference in New Issue