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