Skip to content

Commit

Permalink
OrderIntakeConsumer fixes for less warninig. (#281)
Browse files Browse the repository at this point in the history
## πŸ“ Summary

- Stop building on reorg
- update_onchain_nonces result propagated

## πŸ’‘ Motivation and Context

Warninig annoy me

---

## βœ… I have completed the following steps:

* [x] Run `make lint`
* [x] Run `make test`
* [ ] Added tests (if applicable)
  • Loading branch information
ZanCorDX authored Dec 13, 2024
1 parent 16290b6 commit 5ba3eff
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/rbuilder/src/building/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use reth::{
revm::cached::CachedReads,
};
use reth_db::Database;
use reth_errors::ProviderError;
use reth_provider::{DatabaseProviderFactory, StateProviderFactory};
use std::{fmt::Debug, marker::PhantomData, sync::Arc};
use tokio::sync::{broadcast, broadcast::error::TryRecvError};
Expand Down Expand Up @@ -144,7 +145,9 @@ where
if !self.order_consumer.consume_next_commands()? {
return Ok(false);
}
self.update_onchain_nonces()?;
if !self.update_onchain_nonces()? {
return Ok(false);
}

self.order_consumer
.apply_new_commands(&mut self.block_orders);
Expand All @@ -161,7 +164,11 @@ where
SimulatedOrderCommand::Simulation(sim_order) => Some(sim_order),
SimulatedOrderCommand::Cancellation(_) => None,
});
let nonce_db_ref = self.nonce_cache.get_ref()?;
let nonce_db_ref = match self.nonce_cache.get_ref() {
Ok(nonce_db_ref) => nonce_db_ref,
Err(ProviderError::BlockHashNotFound(_)) => return Ok(false), // This can happen on reorgs since the block is removed
Err(err) => return Err(err.into()),
};
let mut nonces = Vec::new();
for new_order in new_orders {
for nonce in new_order.order.nonces() {
Expand Down

0 comments on commit 5ba3eff

Please sign in to comment.