Skip to content

Commit d7b77e7

Browse files
committed
Implement Snapshot & Restore modules
1 parent 8738030 commit d7b77e7

File tree

11 files changed

+997
-153
lines changed

11 files changed

+997
-153
lines changed

util/merkle/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ elastic-array = "0.10"
88
rand = "0.6.1"
99
hashdb = {path = "../hashdb" }
1010
codechain-crypto = { git = "https://github.com/CodeChain-io/rust-codechain-crypto.git", version = "0.1" }
11+
memorydb = { path = "../memorydb" }
1112
primitives = { git = "https://github.com/CodeChain-io/rust-codechain-primitives.git", version = "0.4" }
1213
rlp = {path = "../rlp" }
1314
rlp_derive = { path = "../rlp_derive" }

util/merkle/src/chunk.rs

Lines changed: 0 additions & 151 deletions
This file was deleted.

util/merkle/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ use ccrypto::BLAKE_NULL_RLP;
3434
use hashdb::{DBValue, HashDB};
3535
use primitives::H256;
3636

37-
pub mod chunk;
3837
mod nibbleslice;
3938
pub mod node;
4039
mod skewed;
40+
pub mod snapshot;
4141
pub mod triedb;
4242
pub mod triedbmut;
4343
pub mod triehash;

util/merkle/src/nibbleslice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::fmt;
1919
use elastic_array::ElasticArray36;
2020

2121

22-
#[derive(Eq, Ord)]
22+
#[derive(Eq, Ord, Copy, Clone)]
2323
pub struct NibbleSlice<'a> {
2424
pub data: &'a [u8],
2525
pub offset: usize,

util/merkle/src/node.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,11 @@ impl<'a> Node<'a> {
113113
}
114114
}
115115
}
116+
117+
pub fn mid(self, offset: usize) -> Self {
118+
match self {
119+
Node::Leaf(partial, value) => Node::Leaf(partial.mid(offset), value),
120+
Node::Branch(partial, child) => Node::Branch(partial.mid(offset), child),
121+
}
122+
}
116123
}

0 commit comments

Comments
 (0)