mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 19:51:02 +00:00
Rewrap all comments to 100 line width (#9490)
* reformat everything again * manual formatting * last manual fix * Fix build
This commit is contained in:
@@ -147,8 +147,8 @@ where
|
||||
|mut map: BTreeMap<&[u8], (ExtrinsicIndex<Number>, Vec<u32>)>, (k, extrinsics)| {
|
||||
match map.entry(k) {
|
||||
Entry::Vacant(entry) => {
|
||||
// ignore temporary values (values that have null value at the end of operation
|
||||
// AND are not in storage at the beginning of operation
|
||||
// ignore temporary values (values that have null value at the end of
|
||||
// operation AND are not in storage at the beginning of operation
|
||||
if let Some(child_info) = child_info.as_ref() {
|
||||
if !overlay
|
||||
.child_storage(child_info, k)
|
||||
@@ -177,8 +177,8 @@ where
|
||||
));
|
||||
},
|
||||
Entry::Occupied(mut entry) => {
|
||||
// we do not need to check for temporary values here, because entry is Occupied
|
||||
// AND we are checking it before insertion
|
||||
// we do not need to check for temporary values here, because entry is
|
||||
// Occupied AND we are checking it before insertion
|
||||
let entry_extrinsics = &mut entry.get_mut().1;
|
||||
entry_extrinsics.extend(extrinsics.into_iter());
|
||||
entry_extrinsics.sort();
|
||||
@@ -246,11 +246,12 @@ where
|
||||
));
|
||||
},
|
||||
Entry::Occupied(mut entry) => {
|
||||
// DigestIndexValue must be sorted. Here we are relying on the fact that digest_build_iterator()
|
||||
// returns blocks in ascending order => we only need to check for duplicates
|
||||
// DigestIndexValue must be sorted. Here we are relying on the fact that
|
||||
// digest_build_iterator() returns blocks in ascending order => we only
|
||||
// need to check for duplicates
|
||||
//
|
||||
// is_dup_block could be true when key has been changed in both digest block
|
||||
// AND other blocks that it covers
|
||||
// is_dup_block could be true when key has been changed in both digest
|
||||
// block AND other blocks that it covers
|
||||
let is_dup_block = entry.get().1.last() == Some(&digest_build_block);
|
||||
if !is_dup_block {
|
||||
entry.get_mut().1.push(digest_build_block.clone());
|
||||
|
||||
@@ -39,7 +39,8 @@ pub struct BuildCache<H, N> {
|
||||
/// Map of changes trie root => set of storage keys that are in this trie.
|
||||
/// The `Option<Vec<u8>>` in inner `HashMap` stands for the child storage key.
|
||||
/// If it is `None`, then the `HashSet` contains keys changed in top-level storage.
|
||||
/// If it is `Some`, then the `HashSet` contains keys changed in child storage, identified by the key.
|
||||
/// If it is `Some`, then the `HashSet` contains keys changed in child storage, identified by
|
||||
/// the key.
|
||||
changed_keys: HashMap<H, HashMap<Option<PrefixedStorageKey>, HashSet<StorageKey>>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,12 @@ pub fn digest_build_iterator<'a, Number: BlockNumber>(
|
||||
/// required for inclusion into changes trie of given block.
|
||||
#[derive(Debug)]
|
||||
pub struct DigestBuildIterator<Number: BlockNumber> {
|
||||
/// Block we're building changes trie for. It could (logically) be a post-end block if we are creating
|
||||
/// skewed digest.
|
||||
/// Block we're building changes trie for. It could (logically) be a post-end block if we are
|
||||
/// creating skewed digest.
|
||||
block: Number,
|
||||
/// Block that is a last block where current configuration is active. We have never yet created anything
|
||||
/// after this block => digest that we're creating can't reference any blocks that are >= end.
|
||||
/// Block that is a last block where current configuration is active. We have never yet created
|
||||
/// anything after this block => digest that we're creating can't reference any blocks that are
|
||||
/// >= end.
|
||||
end: Number,
|
||||
/// Interval of L1 digest blocks.
|
||||
digest_interval: u32,
|
||||
@@ -445,7 +446,8 @@ mod tests {
|
||||
256, 512, 768, 1024, 1280,
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are only 3:
|
||||
1296, 1312, 1328,
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only 9:
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only
|
||||
// 9:
|
||||
1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337,
|
||||
]
|
||||
.iter()
|
||||
@@ -467,8 +469,9 @@ mod tests {
|
||||
[
|
||||
// level3 MUST point to previous 16-1 level2 digests, BUT there are only 5:
|
||||
256, 512, 768, 1024, 1280,
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are NO ANY L1-digests:
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only 3:
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are NO ANY
|
||||
// L1-digests: level3 MUST be a level1 digest of 16-1 previous blocks, BUT
|
||||
// there are only 3:
|
||||
1281, 1282, 1283,
|
||||
]
|
||||
.iter()
|
||||
|
||||
@@ -279,7 +279,8 @@ where
|
||||
if let Some(blocks) = blocks? {
|
||||
if let Ok(blocks) = <DigestIndexValue<Number>>::decode(&mut &blocks[..]) {
|
||||
// filter level0 blocks here because we tend to use digest blocks,
|
||||
// AND digest block changes could also include changes for out-of-range blocks
|
||||
// AND digest block changes could also include changes for out-of-range
|
||||
// blocks
|
||||
let begin = self.begin.clone();
|
||||
let end = self.end.number.clone();
|
||||
let config = self.config.clone();
|
||||
|
||||
@@ -63,9 +63,11 @@ pub type ChildIndexValue = Vec<u8>;
|
||||
pub enum InputPair<Number: BlockNumber> {
|
||||
/// Element of { key => set of extrinsics where key has been changed } element mapping.
|
||||
ExtrinsicIndex(ExtrinsicIndex<Number>, ExtrinsicIndexValue),
|
||||
/// Element of { key => set of blocks/digest blocks where key has been changed } element mapping.
|
||||
/// Element of { key => set of blocks/digest blocks where key has been changed } element
|
||||
/// mapping.
|
||||
DigestIndex(DigestIndex<Number>, DigestIndexValue<Number>),
|
||||
/// Element of { childtrie key => Childchange trie } where key has been changed } element mapping.
|
||||
/// Element of { childtrie key => Childchange trie } where key has been changed } element
|
||||
/// mapping.
|
||||
ChildIndex(ChildIndex<Number>, ChildIndexValue),
|
||||
}
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ pub struct State<'a, H, Number> {
|
||||
/// Configuration that is active at given block.
|
||||
pub config: Configuration,
|
||||
/// Configuration activation block number. Zero if it is the first configuration on the chain,
|
||||
/// or number of the block that have emit NewConfiguration signal (thus activating configuration
|
||||
/// starting from the **next** block).
|
||||
/// or number of the block that have emit NewConfiguration signal (thus activating
|
||||
/// configuration starting from the **next** block).
|
||||
pub zero: Number,
|
||||
/// Underlying changes tries storage reference.
|
||||
pub storage: &'a dyn Storage<H, Number>,
|
||||
@@ -276,8 +276,8 @@ where
|
||||
let parent = state.storage.build_anchor(parent_hash).map_err(|_| ())?;
|
||||
let block = parent.number.clone() + One::one();
|
||||
|
||||
// prepare configuration range - we already know zero block. Current block may be the end block if configuration
|
||||
// has been changed in this block
|
||||
// prepare configuration range - we already know zero block. Current block may be the end block
|
||||
// if configuration has been changed in this block
|
||||
let is_config_changed =
|
||||
match changes.storage(sp_core::storage::well_known_keys::CHANGES_TRIE_CONFIG) {
|
||||
Some(Some(new_config)) => new_config != &state.config.encode()[..],
|
||||
@@ -290,7 +290,8 @@ where
|
||||
end: if is_config_changed { Some(block.clone()) } else { None },
|
||||
};
|
||||
|
||||
// storage errors are considered fatal (similar to situations when runtime fetches values from storage)
|
||||
// storage errors are considered fatal (similar to situations when runtime fetches values from
|
||||
// storage)
|
||||
let (input_pairs, child_input_pairs, digest_input_blocks) = maybe_panic(
|
||||
prepare_input::<B, H, Number>(
|
||||
backend,
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! The best way to understand how this iterator works is to imagine some 2D terrain that have some mountains
|
||||
//! (digest changes tries) and valleys (changes tries for regular blocks). There are gems (blocks) beneath the
|
||||
//! terrain. Given the request to find all gems in the range [X1; X2] this iterator will return **minimal set**
|
||||
//! of points at the terrain (mountains and valleys) inside this range that have to be drilled down to
|
||||
//! search for gems.
|
||||
//! The best way to understand how this iterator works is to imagine some 2D terrain that have some
|
||||
//! mountains (digest changes tries) and valleys (changes tries for regular blocks). There are gems
|
||||
//! (blocks) beneath the terrain. Given the request to find all gems in the range [X1; X2] this
|
||||
//! iterator will return **minimal set** of points at the terrain (mountains and valleys) inside
|
||||
//! this range that have to be drilled down to search for gems.
|
||||
|
||||
use crate::changes_trie::{BlockNumber, ConfigurationRange};
|
||||
use num_traits::One;
|
||||
@@ -50,9 +50,9 @@ pub fn surface_iterator<'a, Number: BlockNumber>(
|
||||
/// Surface iterator - only traverses top-level digests from given range and tries to find
|
||||
/// all valid digest changes.
|
||||
///
|
||||
/// Iterator item is the tuple of (last block of the current point + digest level of the current point).
|
||||
/// Digest level is Some(0) when it is regular block, is Some(non-zero) when it is digest block and None
|
||||
/// if it is skewed digest block.
|
||||
/// Iterator item is the tuple of (last block of the current point + digest level of the current
|
||||
/// point). Digest level is Some(0) when it is regular block, is Some(non-zero) when it is digest
|
||||
/// block and None if it is skewed digest block.
|
||||
pub struct SurfaceIterator<'a, Number: BlockNumber> {
|
||||
config: ConfigurationRange<'a, Number>,
|
||||
begin: Number,
|
||||
|
||||
Reference in New Issue
Block a user