From e1718de01ae728605f0989bb26323389b4053fbd Mon Sep 17 00:00:00 2001 From: dimiandre <dimiandre@gmail.com> Date: Sat, 3 Feb 2024 15:46:17 +0100 Subject: [PATCH 1/5] remove is default from vote_proposal --- src/database.rs | 1 - src/server/tx.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/database.rs b/src/database.rs index 4f790c1..9f02373 100644 --- a/src/database.rs +++ b/src/database.rs @@ -776,7 +776,6 @@ impl Database { "INSERT INTO {}.vote_proposal( vote_proposal_id, vote, - vote_default, voter, tx_id )", diff --git a/src/server/tx.rs b/src/server/tx.rs index faabf56..2be360f 100644 --- a/src/server/tx.rs +++ b/src/server/tx.rs @@ -209,7 +209,6 @@ impl TryFrom<Row> for TxInfo { pub struct VoteProposalTx { pub id: u64, pub vote: bool, - pub is_default: bool, pub voter: String, pub delegations: Vec<String>, #[serde(with = "hex::serde")] @@ -224,7 +223,6 @@ impl TryFrom<Row> for VoteProposalTx { let id = u64::from_be_bytes(id); let vote = value.try_get::<bool, _>("vote")?; - let is_default = value.try_get::<bool, _>("vote_default")?; let voter = value.try_get::<String, _>("voter")?; let tx_id = value.try_get::<Vec<u8>, _>("tx_id")?; @@ -234,7 +232,6 @@ impl TryFrom<Row> for VoteProposalTx { Ok(Self { id, vote, - is_default, voter, delegations, tx_id, From 33d62357ce57a7e0d5119ef00db41e751c2849f8 Mon Sep 17 00:00:00 2001 From: dimiandre <dimiandre@gmail.com> Date: Sat, 3 Feb 2024 16:20:45 +0100 Subject: [PATCH 2/5] try index memo --- src/database.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/database.rs b/src/database.rs index 9f02373..56c6fc3 100644 --- a/src/database.rs +++ b/src/database.rs @@ -582,6 +582,7 @@ impl Database { gas_limit_multiplier, code, data, + memo_hash, return_code )", network @@ -892,6 +893,8 @@ impl Database { // values only set if transaction type is Wrapper let mut fee_amount_per_gas_unit: Option<String> = None; let mut fee_token: Option<String> = None; + let mut memo_hash = tx.header().memo_hash.to_vec(); + let mut gas_limit_multiplier: Option<i64> = 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()); @@ -912,6 +915,7 @@ impl Database { gas_limit_multiplier, code, tx.data().map(|v| v.to_vec()), + memo_hash, return_code, )); } @@ -936,6 +940,7 @@ impl Database { fee_gas_limit_multiplier, code, data, + memo_hash, return_code, )| { b.push_bind(hash) @@ -947,6 +952,7 @@ impl Database { .push_bind(fee_gas_limit_multiplier) .push_bind(code) .push_bind(data) + .push_bind(memo_hash) .push_bind(return_code); }, ) From 4d9b9c40135eca592acf8b62500ac219ff540685 Mon Sep 17 00:00:00 2001 From: dimiandre <dimiandre@gmail.com> Date: Sun, 4 Feb 2024 11:52:55 +0100 Subject: [PATCH 3/5] add code_type column for easy tx type index --- src/database.rs | 21 ++++++++++++++------- src/tables.rs | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/database.rs b/src/database.rs index 56c6fc3..997c8ef 100644 --- a/src/database.rs +++ b/src/database.rs @@ -580,9 +580,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, gas_limit_multiplier, + code_type, code, data, - memo_hash, + memo, return_code )", network @@ -600,7 +601,9 @@ impl Database { for t in txs.iter() { let tx = Tx::try_from(t.as_slice()).map_err(|_| Error::InvalidTxData)?; - let mut code = Default::default(); + let mut code: [u8; 32] = Default::default(); + let mut code_type: String = "wrapper".to_string(); + let mut txid_wrapper: Vec<u8> = vec![]; let mut hash_id = tx.header_hash().to_vec(); @@ -634,7 +637,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<Row> = 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")?; @@ -650,6 +653,8 @@ impl Database { let unknown_type = "unknown".to_string(); let type_tx = checksums_map.get(&code_hex).unwrap_or(&unknown_type); + code_type = type_tx.to_string(); + let data = tx.data().ok_or(Error::InvalidTxData)?; info!("Saving {} transaction", type_tx); @@ -893,7 +898,6 @@ impl Database { // values only set if transaction type is Wrapper let mut fee_amount_per_gas_unit: Option<String> = None; let mut fee_token: Option<String> = None; - let mut memo_hash = tx.header().memo_hash.to_vec(); let mut gas_limit_multiplier: Option<i64> = None; if let TxType::Wrapper(txw) = tx.header().tx_type { @@ -913,9 +917,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, gas_limit_multiplier, + code_type, code, tx.data().map(|v| v.to_vec()), - memo_hash, + tx.memo().map(|v| v.to_vec()), return_code, )); } @@ -938,9 +943,10 @@ impl Database { fee_amount_per_gas_unit, fee_token, fee_gas_limit_multiplier, + code_type, code, data, - memo_hash, + memo, return_code, )| { b.push_bind(hash) @@ -950,9 +956,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_hash) + .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 From fc4459bbd586f97f5a39b4ee7b7ec9e30c6aac63 Mon Sep 17 00:00:00 2001 From: dimiandre <dimiandre@gmail.com> Date: Wed, 21 Feb 2024 10:05:11 +0100 Subject: [PATCH 4/5] merge --- src/database.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/database.rs b/src/database.rs index 5795fe3..1a8b12d 100644 --- a/src/database.rs +++ b/src/database.rs @@ -651,16 +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); -<<<<<<< HEAD code_type = type_tx.to_string(); - let mut data: Vec<u8> = 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)?; - } -======= ->>>>>>> main info!("Saving {} transaction", type_tx); From 9dfa644354b07f9d2e7525d26d8dfedd81a95f09 Mon Sep 17 00:00:00 2001 From: dimiandre <dimiandre@gmail.com> Date: Wed, 21 Feb 2024 10:06:22 +0100 Subject: [PATCH 5/5] change wrapper to unknown --- src/database.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.rs b/src/database.rs index 1a8b12d..ddec976 100644 --- a/src/database.rs +++ b/src/database.rs @@ -601,7 +601,7 @@ impl Database { let tx = Tx::try_from(t.as_slice()).map_err(|e| Error::InvalidTxData(e.to_string()))?; let mut code: [u8; 32] = Default::default(); - let mut code_type: String = "wrapper".to_string(); + let mut code_type: String = "unknown".to_string(); let mut txid_wrapper: Vec<u8> = vec![];