style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -119,8 +119,9 @@ impl KeystoreContainer {
|
||||
/// Construct KeystoreContainer
|
||||
pub fn new(config: &KeystoreConfig) -> Result<Self, Error> {
|
||||
let keystore = Arc::new(match config {
|
||||
KeystoreConfig::Path { path, password } =>
|
||||
LocalKeystore::open(path.clone(), password.clone())?,
|
||||
KeystoreConfig::Path { path, password } => {
|
||||
LocalKeystore::open(path.clone(), password.clone())?
|
||||
},
|
||||
KeystoreConfig::InMemory => LocalKeystore::in_memory(),
|
||||
});
|
||||
|
||||
@@ -884,8 +885,8 @@ where
|
||||
// An archive node that can respond to the `archive` RPC-v2 queries is a node with:
|
||||
// - state pruning in archive mode: The storage of blocks is kept around
|
||||
// - block pruning in archive mode: The block's body is kept around
|
||||
let is_archive_node = state_pruning.as_ref().map(|sp| sp.is_archive()).unwrap_or(false) &&
|
||||
blocks_pruning.is_archive();
|
||||
let is_archive_node = state_pruning.as_ref().map(|sp| sp.is_archive()).unwrap_or(false)
|
||||
&& blocks_pruning.is_archive();
|
||||
let genesis_hash = client.hash(Zero::zero()).ok().flatten().expect("Genesis block exists; qed");
|
||||
if is_archive_node {
|
||||
let archive_v2 = pezsc_rpc_spec_v2::archive::Archive::new(
|
||||
@@ -1043,8 +1044,8 @@ where
|
||||
&mut net_config,
|
||||
network_service_provider.handle(),
|
||||
Arc::clone(&client),
|
||||
config.network.default_peers_set.in_peers as usize +
|
||||
config.network.default_peers_set.out_peers as usize,
|
||||
config.network.default_peers_set.in_peers as usize
|
||||
+ config.network.default_peers_set.out_peers as usize,
|
||||
&spawn_handle,
|
||||
),
|
||||
};
|
||||
@@ -1464,8 +1465,9 @@ where
|
||||
|
||||
if client.requires_full_sync() {
|
||||
match net_config.network_config.sync_mode {
|
||||
SyncMode::LightState { .. } =>
|
||||
return Err("Fast sync doesn't work for archive nodes".into()),
|
||||
SyncMode::LightState { .. } => {
|
||||
return Err("Fast sync doesn't work for archive nodes".into())
|
||||
},
|
||||
SyncMode::Warp => return Err("Warp sync doesn't work for archive nodes".into()),
|
||||
SyncMode::Full => {},
|
||||
}
|
||||
@@ -1474,8 +1476,8 @@ where
|
||||
let genesis_hash = client.info().genesis_hash;
|
||||
|
||||
let (state_request_protocol_config, state_request_protocol_name) = {
|
||||
let num_peer_hint = net_config.network_config.default_peers_set_num_full as usize +
|
||||
net_config.network_config.default_peers_set.reserved_nodes.len();
|
||||
let num_peer_hint = net_config.network_config.default_peers_set_num_full as usize
|
||||
+ net_config.network_config.default_peers_set.reserved_nodes.len();
|
||||
// Allow both outgoing and incoming requests.
|
||||
let (handler, protocol_config) =
|
||||
StateRequestHandler::new::<Net>(&protocol_id, fork_id, client.clone(), num_peer_hint);
|
||||
|
||||
@@ -81,13 +81,14 @@ where
|
||||
.transpose()?
|
||||
.flatten()
|
||||
{
|
||||
Some(block) =>
|
||||
Some(block) => {
|
||||
if binary {
|
||||
output.write_all(&block.encode())?;
|
||||
} else {
|
||||
serde_json::to_writer(&mut output, &block)
|
||||
.map_err(|e| format!("Error writing JSON: {}", e))?;
|
||||
},
|
||||
}
|
||||
},
|
||||
None => return Poll::Ready(Ok(())),
|
||||
}
|
||||
if (block % 10000u32.into()).is_zero() {
|
||||
|
||||
@@ -104,8 +104,8 @@ where
|
||||
/// Returns the number of blocks read thus far.
|
||||
fn read_block_count(&self) -> u64 {
|
||||
match self {
|
||||
BlockIter::Binary { read_block_count, .. } |
|
||||
BlockIter::Json { read_block_count, .. } => *read_block_count,
|
||||
BlockIter::Binary { read_block_count, .. }
|
||||
| BlockIter::Json { read_block_count, .. } => *read_block_count,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ impl<B: BlockT> Speedometer<B> {
|
||||
let speed = diff
|
||||
.saturating_mul(10_000)
|
||||
.checked_div(u128::from(elapsed_ms))
|
||||
.map_or(0.0, |s| s as f64) /
|
||||
10.0;
|
||||
.map_or(0.0, |s| s as f64)
|
||||
/ 10.0;
|
||||
info!("📦 Current best block: {} ({:4.1} bps)", self.best_number, speed);
|
||||
} else {
|
||||
// If the number of blocks can't be converted to a regular integer, then we need a more
|
||||
@@ -375,8 +375,8 @@ where
|
||||
let read_block_count = block_iter.read_block_count();
|
||||
match block_result {
|
||||
Ok(block) => {
|
||||
if read_block_count - link.imported_blocks.load(Ordering::Acquire) >=
|
||||
MAX_PENDING_BLOCKS
|
||||
if read_block_count - link.imported_blocks.load(Ordering::Acquire)
|
||||
>= MAX_PENDING_BLOCKS
|
||||
{
|
||||
// The queue is full, so do not add this block and simply wait
|
||||
// until the queue has made some progress.
|
||||
@@ -392,19 +392,20 @@ where
|
||||
state = Some(ImportState::Reading { block_iter });
|
||||
}
|
||||
},
|
||||
Err(e) =>
|
||||
Err(e) => {
|
||||
return Poll::Ready(Err(Error::Other(format!(
|
||||
"Error reading block #{}: {}",
|
||||
read_block_count, e
|
||||
)))),
|
||||
))))
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
ImportState::WaitingForImportQueueToCatchUp { block_iter, mut delay, block } => {
|
||||
let read_block_count = block_iter.read_block_count();
|
||||
if read_block_count - link.imported_blocks.load(Ordering::Acquire) >=
|
||||
MAX_PENDING_BLOCKS
|
||||
if read_block_count - link.imported_blocks.load(Ordering::Acquire)
|
||||
>= MAX_PENDING_BLOCKS
|
||||
{
|
||||
// Queue is still full, so wait until there is room to insert our block.
|
||||
match Pin::new(&mut delay).poll(cx) {
|
||||
|
||||
@@ -579,9 +579,9 @@ where
|
||||
|
||||
// the block is lower than our last finalized block so it must revert
|
||||
// finality, refusing import.
|
||||
if status == blockchain::BlockStatus::Unknown &&
|
||||
*import_headers.post().number() <= info.finalized_number &&
|
||||
!gap_block
|
||||
if status == blockchain::BlockStatus::Unknown
|
||||
&& *import_headers.post().number() <= info.finalized_number
|
||||
&& !gap_block
|
||||
{
|
||||
return Err(pezsp_blockchain::Error::NotInFinalizedChain);
|
||||
}
|
||||
@@ -590,8 +590,9 @@ where
|
||||
// but the general goal is to only make notifications when we are already fully synced
|
||||
// and get a new chain head.
|
||||
let make_notifications = match origin {
|
||||
BlockOrigin::NetworkBroadcast | BlockOrigin::Own | BlockOrigin::ConsensusBroadcast =>
|
||||
true,
|
||||
BlockOrigin::NetworkBroadcast | BlockOrigin::Own | BlockOrigin::ConsensusBroadcast => {
|
||||
true
|
||||
},
|
||||
BlockOrigin::Genesis | BlockOrigin::NetworkInitialSync | BlockOrigin::File => false,
|
||||
};
|
||||
|
||||
@@ -625,12 +626,14 @@ where
|
||||
let storage_key = PrefixedStorageKey::new_ref(&parent_storage);
|
||||
let storage_key =
|
||||
match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
storage_key,
|
||||
None =>
|
||||
Some((ChildType::ParentKeyId, storage_key)) => {
|
||||
storage_key
|
||||
},
|
||||
None => {
|
||||
return Err(Error::Backend(
|
||||
"Invalid child storage key.".to_string(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
let entry = storage
|
||||
.children_default
|
||||
@@ -680,11 +683,12 @@ where
|
||||
)?;
|
||||
}
|
||||
|
||||
let is_new_best = !gap_block &&
|
||||
(finalized ||
|
||||
match fork_choice {
|
||||
ForkChoiceStrategy::LongestChain =>
|
||||
import_headers.post().number() > &info.best_number,
|
||||
let is_new_best = !gap_block
|
||||
&& (finalized
|
||||
|| match fork_choice {
|
||||
ForkChoiceStrategy::LongestChain => {
|
||||
import_headers.post().number() > &info.best_number
|
||||
},
|
||||
ForkChoiceStrategy::Custom(v) => v,
|
||||
});
|
||||
|
||||
@@ -806,18 +810,21 @@ where
|
||||
let state_action = std::mem::replace(&mut import_block.state_action, StateAction::Skip);
|
||||
let (enact_state, storage_changes) = match (self.block_status(*parent_hash)?, state_action)
|
||||
{
|
||||
(BlockStatus::KnownBad, _) =>
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::KnownBad)),
|
||||
(BlockStatus::KnownBad, _) => {
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::KnownBad))
|
||||
},
|
||||
(
|
||||
BlockStatus::InChainPruned,
|
||||
StateAction::ApplyChanges(pezsc_consensus::StorageChanges::Changes(_)),
|
||||
) => return Ok(PrepareStorageChangesResult::Discard(ImportResult::MissingState)),
|
||||
(_, StateAction::ApplyChanges(changes)) => (true, Some(changes)),
|
||||
(BlockStatus::Unknown, _) =>
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::UnknownParent)),
|
||||
(BlockStatus::Unknown, _) => {
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::UnknownParent))
|
||||
},
|
||||
(_, StateAction::Skip) => (false, None),
|
||||
(BlockStatus::InChainPruned, StateAction::Execute) =>
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::MissingState)),
|
||||
(BlockStatus::InChainPruned, StateAction::Execute) => {
|
||||
return Ok(PrepareStorageChangesResult::Discard(ImportResult::MissingState))
|
||||
},
|
||||
(BlockStatus::InChainPruned, StateAction::ExecuteIfPossible) => (false, None),
|
||||
(_, StateAction::Execute) => (true, None),
|
||||
(_, StateAction::ExecuteIfPossible) => (true, None),
|
||||
@@ -1116,12 +1123,13 @@ where
|
||||
|
||||
let hash_and_number = self.backend.blockchain().number(hash)?.map(|n| (hash, n));
|
||||
match hash_and_number {
|
||||
Some((hash, number)) =>
|
||||
Some((hash, number)) => {
|
||||
if self.backend.have_state_at(hash, number) {
|
||||
Ok(BlockStatus::InChainWithState)
|
||||
} else {
|
||||
Ok(BlockStatus::InChainPruned)
|
||||
},
|
||||
}
|
||||
},
|
||||
None => Ok(BlockStatus::Unknown),
|
||||
}
|
||||
}
|
||||
@@ -1264,8 +1272,9 @@ where
|
||||
let child_info = |storage_key: &Vec<u8>| -> pezsp_blockchain::Result<ChildInfo> {
|
||||
let storage_key = PrefixedStorageKey::new_ref(storage_key);
|
||||
match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
Ok(ChildInfo::new_default(storage_key)),
|
||||
Some((ChildType::ParentKeyId, storage_key)) => {
|
||||
Ok(ChildInfo::new_default(storage_key))
|
||||
},
|
||||
None => Err(Error::Backend("Invalid child storage key.".to_string())),
|
||||
}
|
||||
};
|
||||
@@ -1325,8 +1334,8 @@ where
|
||||
}
|
||||
total_size += size;
|
||||
|
||||
if current_child.is_none() &&
|
||||
pezsp_core::storage::well_known_keys::is_child_storage_key(
|
||||
if current_child.is_none()
|
||||
&& pezsp_core::storage::well_known_keys::is_child_storage_key(
|
||||
next_key.as_slice(),
|
||||
) && !child_roots.contains(value.as_slice())
|
||||
{
|
||||
@@ -1783,10 +1792,12 @@ where
|
||||
.block_status(hash)
|
||||
.map_err(|e| ConsensusError::ClientImport(e.to_string()))?
|
||||
{
|
||||
BlockStatus::InChainWithState | BlockStatus::Queued =>
|
||||
return Ok(ImportResult::AlreadyInChain),
|
||||
BlockStatus::InChainPruned if !import_existing =>
|
||||
return Ok(ImportResult::AlreadyInChain),
|
||||
BlockStatus::InChainWithState | BlockStatus::Queued => {
|
||||
return Ok(ImportResult::AlreadyInChain)
|
||||
},
|
||||
BlockStatus::InChainPruned if !import_existing => {
|
||||
return Ok(ImportResult::AlreadyInChain)
|
||||
},
|
||||
BlockStatus::InChainPruned => {},
|
||||
BlockStatus::Unknown => {},
|
||||
BlockStatus::KnownBad => return Ok(ImportResult::KnownBad),
|
||||
@@ -1952,8 +1963,9 @@ where
|
||||
|
||||
fn block(&self, hash: Block::Hash) -> pezsp_blockchain::Result<Option<SignedBlock<Block>>> {
|
||||
Ok(match (self.header(hash)?, self.body(hash)?, self.justifications(hash)?) {
|
||||
(Some(header), Some(extrinsics), justifications) =>
|
||||
Some(SignedBlock { block: Block::new(header, extrinsics), justifications }),
|
||||
(Some(header), Some(extrinsics), justifications) => {
|
||||
Some(SignedBlock { block: Block::new(header, extrinsics), justifications })
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,10 +176,11 @@ impl<Block: BlockT, Back: Backend<Block>> NotificationPinningWorker<Block, Back>
|
||||
while let Some(message) = self.unpin_message_rx.next().await {
|
||||
match message {
|
||||
UnpinWorkerMessage::AnnouncePin(hash) => self.handle_announce_message(hash),
|
||||
UnpinWorkerMessage::Unpin(hash) =>
|
||||
UnpinWorkerMessage::Unpin(hash) => {
|
||||
if self.handle_unpin_message(hash).is_err() {
|
||||
return;
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
log::debug!(target: LOG_TARGET, "Terminating unpin-worker, stream terminated.")
|
||||
|
||||
@@ -543,8 +543,9 @@ where
|
||||
TransactionImport::NewGood
|
||||
},
|
||||
Err(e) => match e.into_pool_error() {
|
||||
Ok(pezsc_transaction_pool_api::error::Error::AlreadyImported(_)) =>
|
||||
TransactionImport::KnownGood,
|
||||
Ok(pezsc_transaction_pool_api::error::Error::AlreadyImported(_)) => {
|
||||
TransactionImport::KnownGood
|
||||
},
|
||||
Ok(_) => TransactionImport::Bad,
|
||||
Err(_) => {
|
||||
// it is not bad at least, just some internal node logic error, so peer is
|
||||
|
||||
Reference in New Issue
Block a user