mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
chore: convert panic into error (#2035)
This commit is contained in:
@@ -5,6 +5,7 @@ use reth_interfaces::{
|
||||
blockchain_tree::{BlockStatus, BlockchainTreeEngine, BlockchainTreeViewer},
|
||||
consensus::Consensus,
|
||||
events::{ChainEventSubscriptions, NewBlockNotifications},
|
||||
provider::ProviderError,
|
||||
Error,
|
||||
};
|
||||
use reth_primitives::{BlockHash, BlockNumHash, BlockNumber, SealedBlockWithSenders};
|
||||
@@ -80,7 +81,12 @@ impl<DB: Database, C: Consensus, EF: ExecutorFactory> BlockchainTreePendingState
|
||||
&self,
|
||||
block_hash: BlockHash,
|
||||
) -> Result<Box<dyn PostStateDataProvider>, Error> {
|
||||
let Some(post_state) = self.tree.read().post_state_data(block_hash) else { panic!("")};
|
||||
let post_state = self
|
||||
.tree
|
||||
.read()
|
||||
.post_state_data(block_hash)
|
||||
.ok_or(ProviderError::UnknownBlockHash(block_hash))
|
||||
.map(Box::new)?;
|
||||
Ok(Box::new(post_state))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,7 +1015,7 @@ mod tests {
|
||||
let mut executor = Executor::new(chain_spec, db);
|
||||
// touch account
|
||||
executor.commit_changes(
|
||||
hash_map::HashMap::from([(account, RevmAccount { ..default_acc.clone() })]),
|
||||
hash_map::HashMap::from([(account, default_acc.clone())]),
|
||||
true,
|
||||
&mut PostState::default(),
|
||||
);
|
||||
@@ -1039,7 +1039,7 @@ mod tests {
|
||||
);
|
||||
// touch account
|
||||
executor.commit_changes(
|
||||
hash_map::HashMap::from([(account, RevmAccount { ..default_acc })]),
|
||||
hash_map::HashMap::from([(account, default_acc)]),
|
||||
true,
|
||||
&mut PostState::default(),
|
||||
);
|
||||
|
||||
@@ -88,4 +88,7 @@ pub enum ProviderError {
|
||||
/// Thrown when the cache service task dropped
|
||||
#[error("cache service task stopped")]
|
||||
CacheServiceUnavailable,
|
||||
/// Thrown when we failed to lookup a block for the pending state
|
||||
#[error("Unknown block hash: {0:}")]
|
||||
UnknownBlockHash(H256),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user