diff --git a/src/database.rs b/src/database.rs index 5812a72..ddec976 100644 --- a/src/database.rs +++ b/src/database.rs @@ -579,8 +579,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, gas_limit_multiplier, + code_type, code, data, + memo, return_code )", network @@ -598,7 +600,9 @@ impl Database { for t in txs.iter() { let tx = Tx::try_from(t.as_slice()).map_err(|e| Error::InvalidTxData(e.to_string()))?; - let mut code = Default::default(); + let mut code: [u8; 32] = Default::default(); + let mut code_type: String = "unknown".to_string(); + let mut txid_wrapper: Vec = vec![]; let mut hash_id = tx.header_hash().to_vec(); @@ -632,7 +636,7 @@ impl Database { } // look for wrapper tx to link to - let txs = query(&format!("SELECT * FROM {0}.transactions WHERE block_id IN (SELECT block_id FROM {0}.blocks WHERE header_height = {1});", network, block_height-1)) + let txs: Vec = query(&format!("SELECT * FROM {0}.transactions WHERE block_id IN (SELECT block_id FROM {0}.blocks WHERE header_height = {1});", network, block_height-1)) .fetch_all(&mut *sqlx_tx) .await?; txid_wrapper = txs[i].try_get("hash")?; @@ -647,6 +651,8 @@ 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); + code_type = type_tx.to_string(); + info!("Saving {} transaction", type_tx); @@ -897,6 +903,7 @@ impl Database { // values only set if transaction type is Wrapper let mut fee_amount_per_gas_unit: Option = None; let mut fee_token: Option = None; + let mut gas_limit_multiplier: Option = None; if let TxType::Wrapper(txw) = tx.header().tx_type { fee_amount_per_gas_unit = Some(txw.fee.amount_per_gas_unit.to_string_precise()); @@ -915,8 +922,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, gas_limit_multiplier, + code_type, code, tx.data().map(|v| v.to_vec()), + tx.memo().map(|v| v.to_vec()), return_code, )); } @@ -939,8 +948,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, fee_gas_limit_multiplier, + code_type, code, data, + memo, return_code, )| { b.push_bind(hash) @@ -950,8 +961,10 @@ impl Database { .push_bind(fee_amount_per_gas_unit) .push_bind(fee_token) .push_bind(fee_gas_limit_multiplier) + .push_bind(code_type) .push_bind(code) .push_bind(data) + .push_bind(memo) .push_bind(return_code); }, ) diff --git a/src/tables.rs b/src/tables.rs index b268272..28749f3 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -39,8 +39,10 @@ pub fn get_create_transactions_table_query(network: &str) -> String { fee_amount_per_gas_unit TEXT, fee_token TEXT, gas_limit_multiplier BIGINT, + code_type TEXT, code BYTEA, data BYTEA, + memo BYTEA, return_code INTEGER );", network