Skip to content

Commit

Permalink
fix: fix parsing return_data
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Dec 3, 2021
1 parent 850fbd6 commit 7ce7bc3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/web3-indexer/src/error_receipt_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sqlx::PgPool;

use crate::helper::{hex, parse_log, GwLog};

pub const MAX_RETURN_DATA: usize = 32;
pub const MAX_RETURN_DATA: usize = 96;
pub const MAX_ERROR_TX_RECEIPT_BLOCKS: u64 = 3;

pub struct ErrorReceiptIndexer {
Expand Down Expand Up @@ -97,13 +97,14 @@ struct ErrorReceiptRecord {

impl From<ErrorTxReceipt> for ErrorReceiptRecord {
fn from(receipt: ErrorTxReceipt) -> Self {
let return_data_len = std::cmp::min(receipt.return_data.len(), MAX_RETURN_DATA);
let basic_record = ErrorReceiptRecord {
tx_hash: receipt.tx_hash,
block_number: receipt.block_number,
cumulative_gas_used: 0,
gas_used: 0,
status_code: 0,
status_reason: receipt.return_data[..MAX_RETURN_DATA].to_vec(),
status_reason: receipt.return_data[..return_data_len].to_vec(),
};

let gw_log = match receipt.last_log.map(|log| parse_log(&log)).transpose() {
Expand Down

0 comments on commit 7ce7bc3

Please sign in to comment.