From 6ccc36fa39f81e95a4c2d7f76934f559de366002 Mon Sep 17 00:00:00 2001 From: pscott Date: Thu, 15 Apr 2021 17:08:09 +0200 Subject: [PATCH] Move txType parsing outside of forloop --- src_common/ethUstream.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src_common/ethUstream.c b/src_common/ethUstream.c index 5d404fe..2bd36a6 100644 --- a/src_common/ethUstream.c +++ b/src_common/ethUstream.c @@ -249,6 +249,22 @@ static void processV(txContext_t *context) { } static parserStatus_e processTxInternal(txContext_t *context) { + // EIP 2718: TransactionType might be present before the TransactionPayload. + uint8_t txType = *context->workBuffer; + if (txType >= MIN_TX_TYPE && txType <= MAX_TX_TYPE) { + PRINTF("TX TYPE: %u\n", txType); + + // Enumerate through all supported txTypes here... + if (txType == LEGACY_TX) { + context->txType = txType; + context->workBuffer++; + } else { + PRINTF("Transaction type not supported\n"); + return USTREAM_FAULT; + } + } + + // Parse the TransactionPayload. for (;;) { customStatus_e customStatus = CUSTOM_NOT_HANDLED; // EIP 155 style transasction @@ -263,20 +279,7 @@ static parserStatus_e processTxInternal(txContext_t *context) { if (context->commandLength == 0) { return USTREAM_PROCESSING; } - // EIP 2718: TransactionType might be present before the TransactionPayload. - if (*context->workBuffer >= MIN_TX_TYPE && *context->workBuffer <= MAX_TX_TYPE) { - uint8_t maybeType = *context->workBuffer; - PRINTF("TX TYPE: %u\n", maybeType); - // Enumerate through all supported txTypes here... - if (maybeType == LEGACY_TX) { - context->txType = *context->workBuffer; - context->workBuffer++; - } else { - PRINTF("Transaction type not supported\n"); - return USTREAM_FAULT; - } - } if (!context->processingField) { bool canDecode = false; uint32_t offset;