diff --git a/sqlite_db/src/lib.rs b/sqlite_db/src/lib.rs index 7026162..e80eb20 100644 --- a/sqlite_db/src/lib.rs +++ b/sqlite_db/src/lib.rs @@ -83,7 +83,7 @@ struct RunTxRow { end_timestamp: usize, block_number: u64, gas_used: String, - kind: String, + kind: Option, } impl RunTxRow { @@ -275,7 +275,7 @@ impl DbOps for SqliteDb { tx.end_timestamp, tx.block_number, tx.gas_used.to_string(), - tx.kind, + tx.kind.to_owned().unwrap_or("NULL".to_string()), ) }); pool.execute_batch(&format!( @@ -365,7 +365,7 @@ mod tests { end_timestamp: 200, block_number: 1, gas_used: 100, - kind: "test".to_string(), + kind: Some("test".to_string()), }, RunTx { tx_hash: TxHash::from_slice(&[1u8; 32]), @@ -373,7 +373,7 @@ mod tests { end_timestamp: 300, block_number: 2, gas_used: 200, - kind: "test".to_string(), + kind: Some("test".to_string()), }, ]; db.insert_run_txs(run_id as u64, run_txs).unwrap(); diff --git a/src/db/mod.rs b/src/db/mod.rs index 81dd232..92d5770 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -12,7 +12,7 @@ pub struct RunTx { pub end_timestamp: usize, pub block_number: u64, pub gas_used: u128, - pub kind: String, + pub kind: Option, } pub trait DbOps { diff --git a/src/spammer/mod.rs b/src/spammer/mod.rs index d8b62f5..207f710 100644 --- a/src/spammer/mod.rs +++ b/src/spammer/mod.rs @@ -74,8 +74,7 @@ impl OnTxSent for LogCallback { let kind = extra .as_ref() .map(|e| e.get("kind").map(|k| k.to_string())) - .flatten() - .unwrap_or("".to_string()); + .flatten(); let handle = tokio::task::spawn(async move { let res = PendingTransactionBuilder::from_config(&rpc, tx_response); let tx_hash = res.tx_hash(); diff --git a/src/spammer/tx_actor.rs b/src/spammer/tx_actor.rs index 351bbb1..bb12017 100644 --- a/src/spammer/tx_actor.rs +++ b/src/spammer/tx_actor.rs @@ -13,7 +13,7 @@ enum TxActorMessage { SentRunTx { tx_hash: TxHash, start_timestamp: usize, - kind: String, + kind: Option, on_receipt: oneshot::Sender<()>, }, FlushCache { @@ -37,11 +37,11 @@ where pub struct PendingRunTx { tx_hash: TxHash, start_timestamp: usize, - kind: String, + kind: Option, } impl PendingRunTx { - pub fn new(tx_hash: TxHash, start_timestamp: usize, kind: String) -> Self { + pub fn new(tx_hash: TxHash, start_timestamp: usize, kind: Option) -> Self { Self { tx_hash, start_timestamp, @@ -191,7 +191,7 @@ impl TxActorHandle { &self, tx_hash: TxHash, start_timestamp: usize, - kind: String, + kind: Option, ) -> Result<(), Box> { let (sender, receiver) = oneshot::channel(); self.sender