mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: rustfmt (#3532)
This commit is contained in:
@ -177,7 +177,7 @@ impl BlockIndices {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
};
|
};
|
||||||
let Some(new_block_value) = new_hash else {
|
let Some(new_block_value) = new_hash else {
|
||||||
// Old canonical chain had more block than new chain.
|
// Old canonical chain had more block than new chain.
|
||||||
// remove all present block.
|
// remove all present block.
|
||||||
// this is mostly not going to happen as reorg should make new chain in Tree.
|
// this is mostly not going to happen as reorg should make new chain in Tree.
|
||||||
@ -185,7 +185,7 @@ impl BlockIndices {
|
|||||||
removed.push(rem);
|
removed.push(rem);
|
||||||
old_hash = old_hashes.next();
|
old_hash = old_hashes.next();
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
};
|
};
|
||||||
// compare old and new canonical block number
|
// compare old and new canonical block number
|
||||||
match new_block_value.0.cmp(&old_block_value.0) {
|
match new_block_value.0.cmp(&old_block_value.0) {
|
||||||
|
|||||||
@ -903,7 +903,9 @@ impl<DB: Database, C: Consensus, EF: ExecutorFactory> BlockchainTree<DB, C, EF>
|
|||||||
let Some(chain_id) = self.block_indices.get_blocks_chain_id(block_hash) else {
|
let Some(chain_id) = self.block_indices.get_blocks_chain_id(block_hash) else {
|
||||||
warn!(target: "blockchain_tree", ?block_hash, "Block hash not found in block indices");
|
warn!(target: "blockchain_tree", ?block_hash, "Block hash not found in block indices");
|
||||||
// TODO: better error
|
// TODO: better error
|
||||||
return Err(BlockExecutionError::BlockHashNotFoundInChain { block_hash: *block_hash }.into())
|
return Err(
|
||||||
|
BlockExecutionError::BlockHashNotFoundInChain { block_hash: *block_hash }.into()
|
||||||
|
)
|
||||||
};
|
};
|
||||||
let chain = self.chains.remove(&chain_id).expect("To be present");
|
let chain = self.chains.remove(&chain_id).expect("To be present");
|
||||||
|
|
||||||
|
|||||||
@ -533,7 +533,9 @@ where
|
|||||||
match ready!(this.inner.as_mut().poll_flush(cx)) {
|
match ready!(this.inner.as_mut().poll_flush(cx)) {
|
||||||
Err(err) => return Poll::Ready(Err(err.into())),
|
Err(err) => return Poll::Ready(Err(err.into())),
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let Some(message) = this.outgoing_messages.pop_front() else { return Poll::Ready(Ok(())) };
|
let Some(message) = this.outgoing_messages.pop_front() else {
|
||||||
|
return Poll::Ready(Ok(()))
|
||||||
|
};
|
||||||
if let Err(err) = this.inner.as_mut().start_send(message) {
|
if let Err(err) = this.inner.as_mut().start_send(message) {
|
||||||
return Poll::Ready(Err(err.into()))
|
return Poll::Ready(Err(err.into()))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,9 +92,11 @@ impl FromStr for NatResolver {
|
|||||||
"none" => NatResolver::None,
|
"none" => NatResolver::None,
|
||||||
"publicip" | "public-ip" => NatResolver::PublicIp,
|
"publicip" | "public-ip" => NatResolver::PublicIp,
|
||||||
s => {
|
s => {
|
||||||
let Some(ip) = s.strip_prefix("extip:") else { return Err(ParseNatResolverError::UnknownVariant(format!(
|
let Some(ip) = s.strip_prefix("extip:") else {
|
||||||
|
return Err(ParseNatResolverError::UnknownVariant(format!(
|
||||||
"Unknown Nat Resolver: {s}"
|
"Unknown Nat Resolver: {s}"
|
||||||
))) };
|
)))
|
||||||
|
};
|
||||||
NatResolver::ExternalIp(ip.parse::<IpAddr>()?)
|
NatResolver::ExternalIp(ip.parse::<IpAddr>()?)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -81,7 +81,9 @@ where
|
|||||||
let mut block: BlockHashOrNumber = match start_block {
|
let mut block: BlockHashOrNumber = match start_block {
|
||||||
BlockHashOrNumber::Hash(start) => start.into(),
|
BlockHashOrNumber::Hash(start) => start.into(),
|
||||||
BlockHashOrNumber::Number(num) => {
|
BlockHashOrNumber::Number(num) => {
|
||||||
let Some(hash) = self.client.block_hash(num).unwrap_or_default() else { return headers };
|
let Some(hash) = self.client.block_hash(num).unwrap_or_default() else {
|
||||||
|
return headers
|
||||||
|
};
|
||||||
hash.into()
|
hash.into()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1139,9 +1139,7 @@ impl PeersConfig {
|
|||||||
self,
|
self,
|
||||||
optional_file: Option<impl AsRef<Path>>,
|
optional_file: Option<impl AsRef<Path>>,
|
||||||
) -> Result<Self, io::Error> {
|
) -> Result<Self, io::Error> {
|
||||||
let Some(file_path) = optional_file else {
|
let Some(file_path) = optional_file else { return Ok(self) };
|
||||||
return Ok(self)
|
|
||||||
};
|
|
||||||
let reader = match std::fs::File::open(file_path.as_ref()) {
|
let reader = match std::fs::File::open(file_path.as_ref()) {
|
||||||
Ok(file) => io::BufReader::new(file),
|
Ok(file) => io::BufReader::new(file),
|
||||||
Err(e) if e.kind() == ErrorKind::NotFound => return Ok(self),
|
Err(e) if e.kind() == ErrorKind::NotFound => return Ok(self),
|
||||||
@ -1875,7 +1873,11 @@ mod test {
|
|||||||
let mut peer_manager = PeersManager::new(config);
|
let mut peer_manager = PeersManager::new(config);
|
||||||
peer_manager.on_incoming_session_established(given_peer_id, socket_addr);
|
peer_manager.on_incoming_session_established(given_peer_id, socket_addr);
|
||||||
|
|
||||||
let Some(PeerAction::DisconnectBannedIncoming { peer_id }) = peer_manager.queued_actions.pop_front() else { panic!() };
|
let Some(PeerAction::DisconnectBannedIncoming { peer_id }) =
|
||||||
|
peer_manager.queued_actions.pop_front()
|
||||||
|
else {
|
||||||
|
panic!()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(peer_id, given_peer_id)
|
assert_eq!(peer_id, given_peer_id)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,8 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
let Some(end_block) = self.provider().block_number_for_id(newest_block.into())? else {
|
let Some(end_block) = self.provider().block_number_for_id(newest_block.into())? else {
|
||||||
return Err(EthApiError::UnknownBlockNumber) };
|
return Err(EthApiError::UnknownBlockNumber)
|
||||||
|
};
|
||||||
|
|
||||||
// Check that we would not be querying outside of genesis
|
// Check that we would not be querying outside of genesis
|
||||||
if end_block < block_count {
|
if end_block < block_count {
|
||||||
|
|||||||
@ -192,7 +192,9 @@ impl Chain {
|
|||||||
let chain_tip = *self.blocks.last_entry().expect("chain is never empty").key();
|
let chain_tip = *self.blocks.last_entry().expect("chain is never empty").key();
|
||||||
let block_number = match split_at {
|
let block_number = match split_at {
|
||||||
SplitAt::Hash(block_hash) => {
|
SplitAt::Hash(block_hash) => {
|
||||||
let Some(block_number) = self.block_number(block_hash) else { return ChainSplit::NoSplitPending(self)};
|
let Some(block_number) = self.block_number(block_hash) else {
|
||||||
|
return ChainSplit::NoSplitPending(self)
|
||||||
|
};
|
||||||
// If block number is same as tip whole chain is becoming canonical.
|
// If block number is same as tip whole chain is becoming canonical.
|
||||||
if block_number == chain_tip {
|
if block_number == chain_tip {
|
||||||
return ChainSplit::NoSplitCanonical(self)
|
return ChainSplit::NoSplitCanonical(self)
|
||||||
|
|||||||
@ -146,7 +146,7 @@ impl<'a, K: Key + From<Vec<u8>>, C: TrieCursor<K>> TrieWalker<'a, K, C> {
|
|||||||
let Some((key, node)) = self.node(false)? else {
|
let Some((key, node)) = self.node(false)? else {
|
||||||
// If no next node is found, clear the stack.
|
// If no next node is found, clear the stack.
|
||||||
self.stack.clear();
|
self.stack.clear();
|
||||||
return Ok(());
|
return Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
// Overwrite the root node's first nibble
|
// Overwrite the root node's first nibble
|
||||||
@ -178,9 +178,7 @@ impl<'a, K: Key + From<Vec<u8>>, C: TrieCursor<K>> TrieWalker<'a, K, C> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
allow_root_to_child_nibble: bool,
|
allow_root_to_child_nibble: bool,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let Some(subnode) = self.stack.last_mut() else {
|
let Some(subnode) = self.stack.last_mut() else { return Ok(()) };
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if the walker needs to backtrack to the previous level in the trie during its
|
// Check if the walker needs to backtrack to the previous level in the trie during its
|
||||||
// traversal.
|
// traversal.
|
||||||
|
|||||||
Reference in New Issue
Block a user