From 2bbf87569f1833915ccd7aeb2c4164e11d906093 Mon Sep 17 00:00:00 2001 From: Yuun Lim <38443641+yuunlimm@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:11:49 -0700 Subject: [PATCH] handle payload filtered txns for default processor (#423) * handle payload filtered txns for default processor * remove unused one * lint --- .../models/default_models/transactions.rs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/rust/processor/src/db/common/models/default_models/transactions.rs b/rust/processor/src/db/common/models/default_models/transactions.rs index 11e1ccc14..5b4c17eb2 100644 --- a/rust/processor/src/db/common/models/default_models/transactions.rs +++ b/rust/processor/src/db/common/models/default_models/transactions.rs @@ -195,20 +195,24 @@ impl Transaction { match txn_data { TxnData::User(user_txn) => { - let payload = user_txn + let request = &user_txn .request .as_ref() - .expect("Getting user request failed.") - .payload - .as_ref() - .expect("Getting payload failed."); - let payload_cleaned = get_clean_payload(payload, version); - let payload_type = get_payload_type(payload); + .expect("Getting user request failed."); + + let (payload_cleaned, payload_type) = match request.payload.as_ref() { + Some(payload) => { + let payload_cleaned = get_clean_payload(payload, version); + (payload_cleaned, Some(get_payload_type(payload))) + }, + None => (None, None), + }; + ( Self::from_transaction_info_with_data( transaction_info, payload_cleaned, - Some(payload_type), + payload_type, version, transaction_type, user_txn.events.len() as i64, @@ -221,8 +225,11 @@ impl Transaction { ) }, TxnData::Genesis(genesis_txn) => { - let payload = genesis_txn.payload.as_ref().unwrap(); - let payload_cleaned = get_clean_writeset(payload, version); + let payload_cleaned = genesis_txn + .payload + .as_ref() + .map(|payload| get_clean_writeset(payload, version)) + .unwrap_or(None); // It's genesis so no big deal let payload_type = None; (