Skip to content

Commit

Permalink
write to database after successful simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Dec 14, 2023
1 parent 00ff1c6 commit eb6b1fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
10 changes: 1 addition & 9 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,15 +1295,7 @@ mod tests {
let initial_max_fee_per_gas = U256::from(1);
let initial_max_priority_fee_per_gas = U256::from(1);

db.insert_into_tx_hashes(
tx_id,
tx_hash_1,
initial_max_fee_per_gas,
initial_max_priority_fee_per_gas,
)
.await?;

db.insert_into_sent_transactions(
db.insert_tx_broadcast(
tx_id,
tx_hash_1,
initial_max_fee_per_gas,
Expand Down
14 changes: 3 additions & 11 deletions src/tasks/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ async fn broadcast_relayer_txs(
.fill_transaction(&mut typed_transaction, None)
.await?;

tracing::debug!(?tx.id, "Simulating tx");

// Simulate the transaction
match middleware.call(&typed_transaction, None).await {
Ok(_) => {
Expand All @@ -129,7 +131,7 @@ async fn broadcast_relayer_txs(
let tx_hash = H256::from(ethers::utils::keccak256(&raw_signed_tx));

app.db
.insert_into_tx_hashes(
.insert_tx_broadcast(
&tx.id,
tx_hash,
max_fee_per_gas,
Expand All @@ -155,16 +157,6 @@ async fn broadcast_relayer_txs(
}
};

// Insert the tx into
app.db
.insert_into_sent_transactions(
&tx.id,
tx_hash,
max_fee_per_gas,
max_priority_fee_per_gas,
)
.await?;

tracing::info!(id = tx.id, hash = ?tx_hash, "Tx broadcast");
}

Expand Down

0 comments on commit eb6b1fc

Please sign in to comment.