mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Rename: primitives/sr-std -> primitives/sp-std (#4327)
* primitives/sr-std -> primitives/std * fix * fix conflict * rstd -> sp-std * git mv * fix review * fix merge
This commit is contained in:
@@ -23,8 +23,8 @@ mod node_header;
|
||||
mod node_codec;
|
||||
mod trie_stream;
|
||||
|
||||
use rstd::boxed::Box;
|
||||
use rstd::vec::Vec;
|
||||
use sp_std::boxed::Box;
|
||||
use sp_std::vec::Vec;
|
||||
use hash_db::Hasher;
|
||||
/// Our `NodeCodec`-specific error.
|
||||
pub use error::Error;
|
||||
@@ -44,7 +44,7 @@ pub use hash_db::{HashDB as HashDBT, EMPTY_PREFIX};
|
||||
|
||||
#[derive(Default)]
|
||||
/// substrate trie layout
|
||||
pub struct Layout<H>(rstd::marker::PhantomData<H>);
|
||||
pub struct Layout<H>(sp_std::marker::PhantomData<H>);
|
||||
|
||||
impl<H: Hasher> TrieLayout for Layout<H> {
|
||||
const USE_EXTENSION: bool = false;
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
//! `NodeCodec` implementation for Substrate's trie format.
|
||||
|
||||
use rstd::marker::PhantomData;
|
||||
use rstd::ops::Range;
|
||||
use rstd::vec::Vec;
|
||||
use rstd::borrow::Borrow;
|
||||
use sp_std::marker::PhantomData;
|
||||
use sp_std::ops::Range;
|
||||
use sp_std::vec::Vec;
|
||||
use sp_std::borrow::Borrow;
|
||||
use codec::{Encode, Decode, Input, Compact};
|
||||
use hash_db::Hasher;
|
||||
use trie_db::{self, node::{NibbleSlicePlan, NodePlan, NodeHandlePlan}, ChildReference,
|
||||
@@ -30,7 +30,7 @@ use super::{node_header::{NodeHeader, NodeKind}};
|
||||
|
||||
/// Helper struct for trie node decoder. This implements `codec::Input` on a byte slice, while
|
||||
/// tracking the absolute position. This is similar to `std::io::Cursor` but does not implement
|
||||
/// `Read` and `io` is not in `rstd`.
|
||||
/// `Read` and `io` is not in `sp-std`.
|
||||
struct ByteSliceInput<'a> {
|
||||
data: &'a [u8],
|
||||
offset: usize,
|
||||
@@ -94,7 +94,7 @@ impl<H: Hasher> NodeCodecT for NodeCodec<H> {
|
||||
H::hash(<Self as NodeCodecT>::empty_node())
|
||||
}
|
||||
|
||||
fn decode_plan(data: &[u8]) -> rstd::result::Result<NodePlan, Self::Error> {
|
||||
fn decode_plan(data: &[u8]) -> sp_std::result::Result<NodePlan, Self::Error> {
|
||||
let mut input = ByteSliceInput::new(data);
|
||||
match NodeHeader::decode(&mut input)? {
|
||||
NodeHeader::Null => Ok(NodePlan::Empty),
|
||||
@@ -229,7 +229,7 @@ fn partial_from_iterator_encode<I: Iterator<Item = u8>>(
|
||||
nibble_count: usize,
|
||||
node_kind: NodeKind,
|
||||
) -> Vec<u8> {
|
||||
let nibble_count = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count);
|
||||
let nibble_count = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count);
|
||||
|
||||
let mut output = Vec::with_capacity(3 + (nibble_count / nibble_ops::NIBBLE_PER_BYTE));
|
||||
match node_kind {
|
||||
@@ -247,7 +247,7 @@ fn partial_encode(partial: Partial, node_kind: NodeKind) -> Vec<u8> {
|
||||
let number_nibble_encoded = (partial.0).0 as usize;
|
||||
let nibble_count = partial.1.len() * nibble_ops::NIBBLE_PER_BYTE + number_nibble_encoded;
|
||||
|
||||
let nibble_count = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count);
|
||||
let nibble_count = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count);
|
||||
|
||||
let mut output = Vec::with_capacity(3 + partial.1.len());
|
||||
match node_kind {
|
||||
@@ -290,4 +290,3 @@ impl Bitmap {
|
||||
dest[1] = (bitmap / 256) as u8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::trie_constants;
|
||||
use codec::{Encode, Decode, Input, Output};
|
||||
use rstd::iter::once;
|
||||
use sp_std::iter::once;
|
||||
|
||||
/// A node header
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
@@ -72,9 +72,9 @@ impl Decode for NodeHeader {
|
||||
/// Size encoding allows unlimited, length unefficient, representation, but
|
||||
/// is bounded to 16 bit maximum value to avoid possible DOS.
|
||||
pub(crate) fn size_and_prefix_iterator(size: usize, prefix: u8) -> impl Iterator<Item = u8> {
|
||||
let size = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, size);
|
||||
let size = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, size);
|
||||
|
||||
let l1 = rstd::cmp::min(62, size);
|
||||
let l1 = sp_std::cmp::min(62, size);
|
||||
let (first_byte, mut rem) = if size == l1 {
|
||||
(once(prefix + l1 as u8), 0)
|
||||
} else {
|
||||
@@ -94,7 +94,7 @@ pub(crate) fn size_and_prefix_iterator(size: usize, prefix: u8) -> impl Iterator
|
||||
None
|
||||
}
|
||||
};
|
||||
first_byte.chain(rstd::iter::from_fn(next_bytes))
|
||||
first_byte.chain(sp_std::iter::from_fn(next_bytes))
|
||||
}
|
||||
|
||||
/// Encodes size and prefix to a stream output.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use hash_db::Hasher;
|
||||
use trie_root;
|
||||
use codec::Encode;
|
||||
use rstd::vec::Vec;
|
||||
use sp_std::vec::Vec;
|
||||
use crate::trie_constants;
|
||||
use crate::node_header::{NodeKind, size_and_prefix_iterator};
|
||||
use crate::node_codec::Bitmap;
|
||||
@@ -51,7 +51,7 @@ fn branch_node_bit_mask(has_children: impl Iterator<Item = bool>) -> (u8, u8) {
|
||||
|
||||
/// Create a leaf/branch node, encoding a number of nibbles.
|
||||
fn fuse_nibbles_node<'a>(nibbles: &'a [u8], kind: NodeKind) -> impl Iterator<Item = u8> + 'a {
|
||||
let size = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibbles.len());
|
||||
let size = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibbles.len());
|
||||
|
||||
let iter_start = match kind {
|
||||
NodeKind::Leaf => size_and_prefix_iterator(size, trie_constants::LEAF_PREFIX_MASK),
|
||||
@@ -125,7 +125,7 @@ fn branch_node(has_value: bool, has_children: impl Iterator<Item = bool>) -> [u8
|
||||
result
|
||||
}
|
||||
|
||||
fn branch_node_buffered<I>(has_value: bool, has_children: I, output: &mut[u8])
|
||||
fn branch_node_buffered<I>(has_value: bool, has_children: I, output: &mut[u8])
|
||||
where
|
||||
I: Iterator<Item = bool>,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user