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:
@@ -317,8 +317,9 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||
|
||||
let non_canonical: NonCanonicalOverlay<BlockHash, Key> = NonCanonicalOverlay::new(&db)?;
|
||||
let pruning: Option<RefWindow<BlockHash, Key, D>> = match mode {
|
||||
PruningMode::Constrained(Constraints { max_blocks }) =>
|
||||
Some(RefWindow::new(db, max_blocks.unwrap_or(0), ref_counting)?),
|
||||
PruningMode::Constrained(Constraints { max_blocks }) => {
|
||||
Some(RefWindow::new(db, max_blocks.unwrap_or(0), ref_counting)?)
|
||||
},
|
||||
PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => None,
|
||||
};
|
||||
|
||||
@@ -420,10 +421,11 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||
match pruning.next_hash() {
|
||||
// the block record is temporary unavailable, break and try next time
|
||||
Err(Error::StateDb(StateDbError::BlockUnavailable)) => break,
|
||||
res =>
|
||||
res => {
|
||||
if res?.map_or(false, |h| pinned.contains_key(&h)) {
|
||||
break;
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
match pruning.prune_one(commit) {
|
||||
// this branch should not reach as previous `next_hash` don't return error
|
||||
@@ -442,16 +444,18 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||
fn revert_one(&mut self) -> Option<CommitSet<Key>> {
|
||||
match self.mode {
|
||||
PruningMode::ArchiveAll => Some(CommitSet::default()),
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) =>
|
||||
self.non_canonical.revert_one(),
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => {
|
||||
self.non_canonical.revert_one()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn remove(&mut self, hash: &BlockHash) -> Option<CommitSet<Key>> {
|
||||
match self.mode {
|
||||
PruningMode::ArchiveAll => Some(CommitSet::default()),
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) =>
|
||||
self.non_canonical.remove(hash),
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => {
|
||||
self.non_canonical.remove(hash)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,8 +466,8 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||
match self.mode {
|
||||
PruningMode::ArchiveAll => Ok(()),
|
||||
PruningMode::ArchiveCanonical | PruningMode::Constrained(_) => {
|
||||
let have_block = self.non_canonical.have_block(hash) ||
|
||||
self.pruning.as_ref().map_or_else(
|
||||
let have_block = self.non_canonical.have_block(hash)
|
||||
|| self.pruning.as_ref().map_or_else(
|
||||
|| hint(),
|
||||
|pruning| match pruning.have_block(hash, number) {
|
||||
HaveBlock::No => false,
|
||||
@@ -545,11 +549,12 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D> {
|
||||
requested_mode.unwrap_or_default()
|
||||
},
|
||||
|
||||
(false, None, _) =>
|
||||
(false, None, _) => {
|
||||
return Err(StateDbError::Metadata(
|
||||
"An existing StateDb does not have PRUNING_MODE stored in its meta-data".into(),
|
||||
)
|
||||
.into()),
|
||||
.into())
|
||||
},
|
||||
|
||||
(false, Some(stored), None) => stored,
|
||||
|
||||
@@ -694,10 +699,12 @@ fn choose_pruning_mode(
|
||||
) -> Result<PruningMode, StateDbError> {
|
||||
match (stored, requested) {
|
||||
(PruningMode::ArchiveAll, PruningMode::ArchiveAll) => Ok(PruningMode::ArchiveAll),
|
||||
(PruningMode::ArchiveCanonical, PruningMode::ArchiveCanonical) =>
|
||||
Ok(PruningMode::ArchiveCanonical),
|
||||
(PruningMode::Constrained(_), PruningMode::Constrained(requested)) =>
|
||||
Ok(PruningMode::Constrained(requested)),
|
||||
(PruningMode::ArchiveCanonical, PruningMode::ArchiveCanonical) => {
|
||||
Ok(PruningMode::ArchiveCanonical)
|
||||
},
|
||||
(PruningMode::Constrained(_), PruningMode::Constrained(requested)) => {
|
||||
Ok(PruningMode::Constrained(requested))
|
||||
},
|
||||
(stored, requested) => Err(StateDbError::IncompatiblePruningModes { requested, stored }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ fn discard_descendants<BlockHash: Hash, Key: Hash>(
|
||||
while let Some(i) = level.blocks.iter().position(|overlay| {
|
||||
parents
|
||||
.get(&overlay.hash)
|
||||
.expect("there is a parent entry for each entry in levels; qed") ==
|
||||
hash
|
||||
.expect("there is a parent entry for each entry in levels; qed")
|
||||
== hash
|
||||
}) {
|
||||
let overlay = level.remove(i);
|
||||
let mut num_pinned = discard_descendants(
|
||||
@@ -285,8 +285,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
return Err(StateDbError::InvalidParent);
|
||||
}
|
||||
}
|
||||
let level = if self.levels.is_empty() ||
|
||||
number == front_block_number + self.levels.len() as u64
|
||||
let level = if self.levels.is_empty()
|
||||
|| number == front_block_number + self.levels.len() as u64
|
||||
{
|
||||
self.levels.push_back(OverlayLevel::new());
|
||||
self.levels.back_mut().expect("can't be empty after insertion; qed")
|
||||
@@ -578,8 +578,8 @@ mod tests {
|
||||
use pezsp_core::H256;
|
||||
|
||||
fn contains(overlay: &NonCanonicalOverlay<H256, H256>, key: u64) -> bool {
|
||||
overlay.get(&H256::from_low_u64_be(key)) ==
|
||||
Some(H256::from_low_u64_be(key).as_bytes().to_vec())
|
||||
overlay.get(&H256::from_low_u64_be(key))
|
||||
== Some(H256::from_low_u64_be(key).as_bytes().to_vec())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user