chore: rustfmt (#3532)

This commit is contained in:
Matthias Seitz
2023-07-02 12:51:43 +02:00
committed by GitHub
parent 419a35e9c9
commit 1c796f24fc
9 changed files with 28 additions and 17 deletions

View File

@ -185,7 +185,7 @@ impl BlockIndices {
removed.push(rem);
old_hash = old_hashes.next();
}
break;
break
};
// compare old and new canonical block number
match new_block_value.0.cmp(&old_block_value.0) {

View File

@ -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 {
warn!(target: "blockchain_tree", ?block_hash, "Block hash not found in block indices");
// 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");

View File

@ -533,7 +533,9 @@ where
match ready!(this.inner.as_mut().poll_flush(cx)) {
Err(err) => return Poll::Ready(Err(err.into())),
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) {
return Poll::Ready(Err(err.into()))
}

View File

@ -92,9 +92,11 @@ impl FromStr for NatResolver {
"none" => NatResolver::None,
"publicip" | "public-ip" => NatResolver::PublicIp,
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}"
))) };
)))
};
NatResolver::ExternalIp(ip.parse::<IpAddr>()?)
}
};

View File

@ -81,7 +81,9 @@ where
let mut block: BlockHashOrNumber = match start_block {
BlockHashOrNumber::Hash(start) => start.into(),
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()
}
};

View File

@ -1139,9 +1139,7 @@ impl PeersConfig {
self,
optional_file: Option<impl AsRef<Path>>,
) -> Result<Self, io::Error> {
let Some(file_path) = optional_file else {
return Ok(self)
};
let Some(file_path) = optional_file else { return Ok(self) };
let reader = match std::fs::File::open(file_path.as_ref()) {
Ok(file) => io::BufReader::new(file),
Err(e) if e.kind() == ErrorKind::NotFound => return Ok(self),
@ -1875,7 +1873,11 @@ mod test {
let mut peer_manager = PeersManager::new(config);
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)
}

View File

@ -64,7 +64,8 @@ where
}
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
if end_block < block_count {

View File

@ -192,7 +192,9 @@ impl Chain {
let chain_tip = *self.blocks.last_entry().expect("chain is never empty").key();
let block_number = match split_at {
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 == chain_tip {
return ChainSplit::NoSplitCanonical(self)

View File

@ -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 {
// If no next node is found, clear the stack.
self.stack.clear();
return Ok(());
return Ok(())
};
// 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,
allow_root_to_child_nibble: bool,
) -> Result<(), DatabaseError> {
let Some(subnode) = self.stack.last_mut() else {
return Ok(());
};
let Some(subnode) = self.stack.last_mut() else { return Ok(()) };
// Check if the walker needs to backtrack to the previous level in the trie during its
// traversal.