Rewrap all comments to 100 line width (#9490)

* reformat everything again

* manual formatting

* last manual fix

* Fix build
This commit is contained in:
Kian Paimani
2021-08-11 16:56:55 +02:00
committed by GitHub
parent 8180c58700
commit abd08e29ce
258 changed files with 1776 additions and 1447 deletions
+11 -8
View File
@@ -25,15 +25,17 @@
//! There's a limit of 32 blocks that may have the same block number in the canonicalization window.
//!
//! Canonicalization function selects one root from the top of the tree and discards all other roots
//! and their subtrees. Upon canonicalization all trie nodes that were inserted in the block are added to
//! the backing DB and block tracking is moved to the pruning window, where no forks are allowed.
//! and their subtrees. Upon canonicalization all trie nodes that were inserted in the block are
//! added to the backing DB and block tracking is moved to the pruning window, where no forks are
//! allowed.
//!
//! # Canonicalization vs Finality
//! Database engine uses a notion of canonicality, rather then finality. A canonical block may not be yet finalized
//! from the perspective of the consensus engine, but it still can't be reverted in the database. Most of the time
//! during normal operation last canonical block is the same as last finalized. However if finality stall for a
//! long duration for some reason, there's only a certain number of blocks that can fit in the non-canonical overlay,
//! so canonicalization of an unfinalized block may be forced.
//! Database engine uses a notion of canonicality, rather then finality. A canonical block may not
//! be yet finalized from the perspective of the consensus engine, but it still can't be reverted in
//! the database. Most of the time during normal operation last canonical block is the same as last
//! finalized. However if finality stall for a long duration for some reason, there's only a certain
//! number of blocks that can fit in the non-canonical overlay, so canonicalization of an
//! unfinalized block may be forced.
//!
//! # Pruning.
//! See `RefWindow` for pruning algorithm details. `StateDb` prunes on each canonicalization until
@@ -177,7 +179,8 @@ pub struct CommitSet<H: Hash> {
/// Pruning constraints. If none are specified pruning is
#[derive(Default, Debug, Clone, Eq, PartialEq)]
pub struct Constraints {
/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical states.
/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical
/// states.
pub max_blocks: Option<u32>,
/// Maximum memory in the pruning overlay.
pub max_mem: Option<usize>,
+14 -5
View File
@@ -241,7 +241,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
})
}
/// Insert a new block into the overlay. If inserted on the second level or lover expects parent to be present in the window.
/// Insert a new block into the overlay. If inserted on the second level or lover expects parent
/// to be present in the window.
pub fn insert<E: fmt::Debug>(
&mut self,
hash: &BlockHash,
@@ -501,7 +502,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
!self.pending_canonicalizations.contains(hash)
}
/// Revert a single level. Returns commit set that deletes the journal or `None` if not possible.
/// Revert a single level. Returns commit set that deletes the journal or `None` if not
/// possible.
pub fn revert_one(&mut self) -> Option<CommitSet<Key>> {
self.levels.pop_back().map(|level| {
let mut commit = CommitSet::default();
@@ -514,7 +516,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
})
}
/// Revert a single block. Returns commit set that deletes the journal or `None` if not possible.
/// Revert a single block. Returns commit set that deletes the journal or `None` if not
/// possible.
pub fn remove(&mut self, hash: &BlockHash) -> Option<CommitSet<Key>> {
let mut commit = CommitSet::default();
let level_count = self.levels.len();
@@ -548,7 +551,8 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
self.pending_insertions.reverse();
for hash in self.pending_insertions.drain(..) {
self.parents.remove(&hash);
// find a level. When iterating insertions backwards the hash is always last in the level.
// find a level. When iterating insertions backwards the hash is always last in the
// level.
let level_index = self
.levels
.iter()
@@ -870,6 +874,7 @@ mod tests {
fn complex_tree() {
let mut db = make_db(&[]);
#[rustfmt::skip]
// - 1 - 1_1 - 1_1_1
// \ 1_2 - 1_2_1
// \ 1_2_2
@@ -1027,6 +1032,7 @@ mod tests {
fn keeps_pinned() {
let mut db = make_db(&[]);
#[rustfmt::skip]
// - 0 - 1_1
// \ 1_2
@@ -1053,6 +1059,7 @@ mod tests {
fn keeps_pinned_ref_count() {
let mut db = make_db(&[]);
#[rustfmt::skip]
// - 0 - 1_1
// \ 1_2
// \ 1_3
@@ -1084,6 +1091,7 @@ mod tests {
fn pin_keeps_parent() {
let mut db = make_db(&[]);
#[rustfmt::skip]
// - 0 - 1_1 - 2_1
// \ 1_2
@@ -1178,7 +1186,8 @@ mod tests {
db.commit(&commit);
overlay.apply_pending();
// add another block at top level. It should reuse journal index 0 of previously discarded block
// add another block at top level. It should reuse journal index 0 of previously discarded
// block
let h22 = H256::random();
db.commit(&overlay.insert::<io::Error>(&h22, 12, &h2, make_changeset(&[22], &[])).unwrap());
assert_eq!(overlay.levels[0].blocks[0].journal_index, 1);
+4 -3
View File
@@ -219,9 +219,10 @@ impl<BlockHash: Hash, Key: Hash> RefWindow<BlockHash, Key> {
/// Revert all pending changes
pub fn revert_pending(&mut self) {
// Revert pending deletions.
// Note that pending insertions might cause some existing deletions to be removed from `death_index`
// We don't bother to track and revert that for now. This means that a few nodes might end up no being
// deleted in case transaction fails and `revert_pending` is called.
// Note that pending insertions might cause some existing deletions to be removed from
// `death_index` We don't bother to track and revert that for now. This means that a few
// nodes might end up no being deleted in case transaction fails and `revert_pending` is
// called.
self.death_rows.truncate(self.death_rows.len() - self.pending_canonicalizations);
if self.count_insertions {
let new_max_block = self.death_rows.len() as u64 + self.pending_number;