From ec415ab1cd110c13a7c080e7a2789c6a77ddd62b Mon Sep 17 00:00:00 2001 From: sleepy ramen Date: Fri, 16 Feb 2024 11:28:22 +0100 Subject: [PATCH] fix: the invalid tx error when trasnction has failed (#136) Some failed transactions have failed because they don't have data. So we don't try to get the data on failed transaction at all. --- src/database.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/database.rs b/src/database.rs index 4ffc844..398e260 100644 --- a/src/database.rs +++ b/src/database.rs @@ -647,17 +647,14 @@ impl Database { let code_hex = hex::encode(code.as_slice()); let unknown_type = "unknown".to_string(); let type_tx = checksums_map.get(&code_hex).unwrap_or(&unknown_type); - let mut data: Vec = vec![]; - if type_tx != "tx_bridge_pool" { - // "tx_bridge_pool" doesn't have their data in the data section anymore ? - data = tx.data().ok_or(Error::InvalidTxData)?; - } info!("Saving {} transaction", type_tx); // decode tx_transfer, tx_bond and tx_unbound to store the decoded data in their tables // if the transaction has failed don't try to decode because the changes are not included and the data might not be correct if return_code.unwrap() == 0 { + let data = tx.data().ok_or(Error::InvalidTxData)?; + match type_tx.as_str() { "tx_transfer" => { let transfer = token::Transfer::try_from_slice(&data[..])?;