cleanup
This commit is contained in:
parent
6454fbfcfc
commit
6518c578fb
|
@ -870,14 +870,14 @@ const ETHRoot *ETHExecutionPayloadHeaderGetReceiptsRoot(
|
|||
const ETHExecutionPayloadHeader *execution);
|
||||
|
||||
/**
|
||||
* Execution logs bloom.
|
||||
* Execution logs Bloom.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t bytes[256];
|
||||
} ETHLogsBloom;
|
||||
|
||||
/**
|
||||
* Obtains the logs bloom of a given execution payload header.
|
||||
* Obtains the logs Bloom of a given execution payload header.
|
||||
*
|
||||
* - The returned value is allocated in the given execution payload header.
|
||||
* It must neither be released nor written to, and the execution payload
|
||||
|
@ -885,7 +885,7 @@ typedef struct {
|
|||
*
|
||||
* @param execution Execution payload header.
|
||||
*
|
||||
* @return Execution logs bloom.
|
||||
* @return Execution logs Bloom.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHLogsBloom *ETHExecutionPayloadHeaderGetLogsBloom(
|
||||
|
@ -1501,13 +1501,14 @@ typedef struct ETHReceipts ETHReceipts;
|
|||
* receipts data for a given transaction hash. For verification, it is
|
||||
* necessary to obtain the receipt for _all_ transactions within a block.
|
||||
* Pass a JSON array containing _all_ receipt's `result` as `receiptsJson`.
|
||||
* The receipts need to be in the same order as the transactions.
|
||||
* The receipts need to be in the same order as the `transactions`.
|
||||
*
|
||||
* - The receipt sequence must be destroyed with `ETHReceiptsDestroy`
|
||||
* once no longer needed, to release memory.
|
||||
*
|
||||
* @param receiptsRoot Execution receipts root.
|
||||
* @param receiptsJson Buffer with JSON receipts list. NULL-terminated.
|
||||
* @param transactions Transaction sequence.
|
||||
*
|
||||
* @return Pointer to an initialized receipt sequence - If successful.
|
||||
* @return `NULL` - If the given `receiptsJson` is malformed or incompatible.
|
||||
|
@ -1517,7 +1518,8 @@ typedef struct ETHReceipts ETHReceipts;
|
|||
ETH_RESULT_USE_CHECK
|
||||
ETHReceipts *ETHReceiptsCreateFromJson(
|
||||
const ETHRoot *receiptsRoot,
|
||||
const char *receiptsJson);
|
||||
const char *receiptsJson,
|
||||
const ETHTransactions *transactions);
|
||||
|
||||
/**
|
||||
* Destroys a receipt sequence.
|
||||
|
@ -1620,7 +1622,7 @@ ETH_RESULT_USE_CHECK
|
|||
const uint64_t *ETHReceiptGetGasUsed(const ETHReceipt *receipt);
|
||||
|
||||
/**
|
||||
* Obtains the logs bloom of a receipt.
|
||||
* Obtains the logs Bloom of a receipt.
|
||||
*
|
||||
* - The returned value is allocated in the given receipt.
|
||||
* It must neither be released nor written to, and the receipt
|
||||
|
@ -1628,7 +1630,7 @@ const uint64_t *ETHReceiptGetGasUsed(const ETHReceipt *receipt);
|
|||
*
|
||||
* @param receipt Receipt.
|
||||
*
|
||||
* @return Logs bloom.
|
||||
* @return Logs Bloom.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHLogsBloom *ETHReceiptGetLogsBloom(const ETHReceipt *receipt);
|
||||
|
|
|
@ -1038,7 +1038,7 @@ func ETHExecutionPayloadHeaderGetReceiptsRoot(
|
|||
|
||||
func ETHExecutionPayloadHeaderGetLogsBloom(
|
||||
execution: ptr ExecutionPayloadHeader): ptr BloomLogs {.exported.} =
|
||||
## Obtains the logs bloom of a given execution payload header.
|
||||
## Obtains the logs Bloom of a given execution payload header.
|
||||
##
|
||||
## * The returned value is allocated in the given execution payload header.
|
||||
## It must neither be released nor written to, and the execution payload
|
||||
|
@ -1048,7 +1048,7 @@ func ETHExecutionPayloadHeaderGetLogsBloom(
|
|||
## * `execution` - Execution payload header.
|
||||
##
|
||||
## Returns:
|
||||
## * Execution logs bloom.
|
||||
## * Execution logs Bloom.
|
||||
addr execution[].logs_bloom
|
||||
|
||||
func ETHExecutionPayloadHeaderGetPrevRandao(
|
||||
|
@ -1988,7 +1988,8 @@ type
|
|||
|
||||
proc ETHReceiptsCreateFromJson(
|
||||
receiptsRoot: ptr Eth2Digest,
|
||||
receiptsJson: cstring): ptr seq[ETHReceipt] {.exported.} =
|
||||
receiptsJson: cstring,
|
||||
transactions: ptr seq[ETHTransaction]): ptr seq[ETHReceipt] {.exported.} =
|
||||
## Verifies that JSON receipts data is valid and that it matches
|
||||
## the given `receiptsRoot`.
|
||||
##
|
||||
|
@ -1996,7 +1997,7 @@ proc ETHReceiptsCreateFromJson(
|
|||
## receipts data for a given transaction hash. For verification, it is
|
||||
## necessary to obtain the receipt for _all_ transactions within a block.
|
||||
## Pass a JSON array containing _all_ receipt's `result` as `receiptsJson`.
|
||||
## The receipts need to be in the same order as the transactions.
|
||||
## The receipts need to be in the same order as the `transactions`.
|
||||
##
|
||||
## * The receipt sequence must be destroyed with `ETHReceiptsDestroy`
|
||||
## once no longer needed, to release memory.
|
||||
|
@ -2004,6 +2005,7 @@ proc ETHReceiptsCreateFromJson(
|
|||
## Parameters:
|
||||
## * `receiptsRoot` - Execution receipts root.
|
||||
## * `receiptsJson` - Buffer with JSON receipts list. NULL-terminated.
|
||||
## * `transactions` - Transaction sequence.
|
||||
##
|
||||
## Returns:
|
||||
## * Pointer to an initialized receipt sequence - If successful.
|
||||
|
@ -2021,6 +2023,8 @@ proc ETHReceiptsCreateFromJson(
|
|||
fromJson(node, argName = "", datas)
|
||||
except KeyError, ValueError:
|
||||
return nil
|
||||
if datas.len != ETHTransactionsGetCount(transactions):
|
||||
return nil
|
||||
|
||||
var
|
||||
recs = newSeqOfCap[ETHReceipt](datas.len)
|
||||
|
@ -2111,7 +2115,7 @@ proc ETHReceiptsCreateFromJson(
|
|||
ReceiptStatusType.Status,
|
||||
root: rec.hash,
|
||||
status: rec.status,
|
||||
gasUsed: distinctBase(data.gasUsed), # Validated in sanity checks.
|
||||
gasUsed: distinctBase(data.gasUsed), # Validated during sanity checks.
|
||||
logsBloom: BloomLogs(data: rec.bloom),
|
||||
logs: rec.logs.mapIt(ETHLog(
|
||||
address: ExecutionAddress(data: it.address),
|
||||
|
@ -2242,7 +2246,7 @@ func ETHReceiptGetGasUsed(
|
|||
|
||||
func ETHReceiptGetLogsBloom(
|
||||
receipt: ptr ETHReceipt): ptr BloomLogs {.exported.} =
|
||||
## Obtains the logs bloom of a receipt.
|
||||
## Obtains the logs Bloom of a receipt.
|
||||
##
|
||||
## * The returned value is allocated in the given receipt.
|
||||
## It must neither be released nor written to, and the receipt
|
||||
|
@ -2252,7 +2256,7 @@ func ETHReceiptGetLogsBloom(
|
|||
## * `receipt` - Receipt.
|
||||
##
|
||||
## Returns:
|
||||
## * Logs bloom.
|
||||
## * Logs Bloom.
|
||||
addr receipt[].logsBloom
|
||||
|
||||
func ETHReceiptGetLogs(
|
||||
|
|
|
@ -413,7 +413,7 @@ int main(void)
|
|||
void *sampleReceiptsJson = readEntireFile(
|
||||
__DIR__ "/test_files/receipts.json", /* numBytes: */ NULL);
|
||||
ETHReceipts *receipts =
|
||||
ETHReceiptsCreateFromJson(&sampleReceiptsRoot, sampleReceiptsJson);
|
||||
ETHReceiptsCreateFromJson(&sampleReceiptsRoot, sampleReceiptsJson, transactions);
|
||||
check(receipts);
|
||||
free(sampleReceiptsJson);
|
||||
|
||||
|
|
Loading…
Reference in New Issue