pub struct PatriciaTree { /* private fields */ }Expand description
葉の集まり。キーは木のキー(状態のキーの SHA3-256)、値は状態のハッシュ。
Implementations§
Source§impl PatriciaTree
impl PatriciaTree
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn from_nodes(nodes: impl IntoIterator<Item = (Position, TreeNode)>) -> Self
pub fn from_nodes(nodes: impl IntoIterator<Item = (Position, TreeNode)>) -> Self
しまったノードから戻す。葉の並びは葉のノードから、途中のハッシュは枝が持つ子のハッシュから埋めるので、 ハッシュを求め直さない。ノードは1つの木の全部で、位置と合っていること
Sourcepub fn take_node_changes(&mut self) -> Vec<(Position, Option<TreeNode>)>
pub fn take_node_changes(&mut self) -> Vec<(Position, Option<TreeNode>)>
前に呼んでから変わったノード。位置と、今のノードか、なくなったら None
Sourcepub fn track_node_changes(&mut self, track: bool)
pub fn track_node_changes(&mut self, track: bool)
ノードの変化を覚えるか。覚えないあいだは、根を求めても組んだノードを取っておかない。
覚え始めるときは、PatriciaTree::forget_node_changes でそれまでのものを捨ててから
Sourcepub fn forget_node_changes(&mut self)
pub fn forget_node_changes(&mut self)
ノードの変化を覚えるのをやめて、捨てる。DB にあるものと同じ木を組み直したとき
pub fn get(&self, key: &Hash256) -> Option<Hash256>
Sourcepub fn root(&mut self) -> Hash256
pub fn root(&mut self) -> Hash256
根のハッシュ。空なら EMPTY_ROOT。
Trait Implementations§
Source§impl Clone for PatriciaTree
impl Clone for PatriciaTree
Source§fn clone(&self) -> PatriciaTree
fn clone(&self) -> PatriciaTree
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PatriciaTree
impl Debug for PatriciaTree
Source§impl Default for PatriciaTree
impl Default for PatriciaTree
Source§fn default() -> PatriciaTree
fn default() -> PatriciaTree
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PatriciaTree
impl RefUnwindSafe for PatriciaTree
impl Send for PatriciaTree
impl Sync for PatriciaTree
impl Unpin for PatriciaTree
impl UnsafeUnpin for PatriciaTree
impl UnwindSafe for PatriciaTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more