pub struct Tree { /* private fields */ }
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn main(&self) -> Option<&Branch>
pub fn main(&self) -> Option<&Branch>
Examples found in repository?
examples/tree.rs (line 13)
2fn main() {
3 let mut tree = Tree::default();
4 tree.insert([0x11; 32], [0x00; 32], 1);
5 tree.insert([0x22; 32], [0x11; 32], 1);
6 tree.insert([0x33; 32], [0x22; 32], 1);
7 tree.insert([0x44; 32], [0x33; 32], 1);
8 tree.insert([0x55; 32], [0x22; 32], 1);
9 tree.insert([0x66; 32], [0x00; 32], 1);
10 tree.insert([0x77; 32], [0x55; 32], 0);
11 tree.sort_branches();
12 println!("{tree:x?}");
13 println!("{:x?}", tree.main());
14}
pub fn size(&self) -> usize
pub fn hashes(&self, trust_fork_after_blocks: usize) -> (Vec<Hash>, Vec<Hash>)
pub fn hashes_dynamic(&self, trust_fork_after_blocks: usize) -> Vec<Hash> ⓘ
pub fn get(&self, hash: &Hash) -> Option<&Hash>
Sourcepub fn insert(
&mut self,
hash: Hash,
previous_hash: Hash,
timestamp: u32,
) -> Option<bool>
pub fn insert( &mut self, hash: Hash, previous_hash: Hash, timestamp: u32, ) -> Option<bool>
Examples found in repository?
examples/tree.rs (line 4)
2fn main() {
3 let mut tree = Tree::default();
4 tree.insert([0x11; 32], [0x00; 32], 1);
5 tree.insert([0x22; 32], [0x11; 32], 1);
6 tree.insert([0x33; 32], [0x22; 32], 1);
7 tree.insert([0x44; 32], [0x33; 32], 1);
8 tree.insert([0x55; 32], [0x22; 32], 1);
9 tree.insert([0x66; 32], [0x00; 32], 1);
10 tree.insert([0x77; 32], [0x55; 32], 0);
11 tree.sort_branches();
12 println!("{tree:x?}");
13 println!("{:x?}", tree.main());
14}
Sourcepub fn sort_branches(&mut self)
pub fn sort_branches(&mut self)
Examples found in repository?
examples/tree.rs (line 11)
2fn main() {
3 let mut tree = Tree::default();
4 tree.insert([0x11; 32], [0x00; 32], 1);
5 tree.insert([0x22; 32], [0x11; 32], 1);
6 tree.insert([0x33; 32], [0x22; 32], 1);
7 tree.insert([0x44; 32], [0x33; 32], 1);
8 tree.insert([0x55; 32], [0x22; 32], 1);
9 tree.insert([0x66; 32], [0x00; 32], 1);
10 tree.insert([0x77; 32], [0x55; 32], 0);
11 tree.sort_branches();
12 println!("{tree:x?}");
13 println!("{:x?}", tree.main());
14}
pub fn clear(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tree
impl RefUnwindSafe for Tree
impl Send for Tree
impl Sync for Tree
impl Unpin for Tree
impl UnwindSafe for Tree
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