pub enum TreeNode {
Leaf {
path: Vec<u8>,
value: Hash256,
},
Branch {
path: Vec<u8>,
links: Box<[Option<Hash256>; 16]>,
},
}Expand description
木のノード。経路はニブル(0 から 15)の並び。
Variants§
Implementations§
Source§impl TreeNode
impl TreeNode
Sourcepub fn hash(&self) -> Hash256
pub fn hash(&self) -> Hash256
ノードのハッシュ。catapult の LeafTreeNode と BranchTreeNode の hash。
符号化した経路に、葉なら値を、枝なら16の子のハッシュ(ないところは0)を続けた SHA3-256。
pub fn path(&self) -> &[u8] ⓘ
Sourcepub fn decode_all(bytes: &[u8]) -> Result<Vec<Self>, TreeNodeDecodeError>
pub fn decode_all(bytes: &[u8]) -> Result<Vec<Self>, TreeNodeDecodeError>
ノードを並べたバイト列から読む。catapult の PatriciaTreeSerializer の形で、ノードの状態の経路を問い合わせた答えもこれ。
葉 u8 0xFF u8 ニブルの数 経路(2ニブルで1バイト、奇数なら最後の下位は0) [32] 値
枝 u8 0x00 u8 ニブルの数 経路 u16 子があるところのビット [32] 子のハッシュをビットの順にTrait Implementations§
impl Eq for TreeNode
impl StructuralPartialEq for TreeNode
Auto Trait Implementations§
impl Freeze for TreeNode
impl RefUnwindSafe for TreeNode
impl Send for TreeNode
impl Sync for TreeNode
impl Unpin for TreeNode
impl UnsafeUnpin for TreeNode
impl UnwindSafe for TreeNode
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