Skip to content

Commit cd1dfaf

Browse files
committed
Compress snapshot files
Fix: ##220
1 parent a5518a8 commit cd1dfaf

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sync/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ parking_lot = "0.5"
1818
patricia-trie = { path = "../util/patricia_trie" }
1919
rand = "0.5.3"
2020
rlp = { path = "../util/rlp" }
21+
snap = "0.2"
2122
time = "0.1"
2223
triehash = { path = "../util/triehash" }
2324

sync/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern crate patricia_trie as trie;
3030
extern crate rand;
3131
#[cfg_attr(test, macro_use)]
3232
extern crate rlp;
33+
extern crate snap;
3334
extern crate time;
3435
extern crate triehash;
3536

sync/src/snapshot/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn write_snapshot(db: Arc<KeyValueDB>, path: PathBuf, root: &H256) -> Result<(),
9191
}
9292

9393
{
94-
let mut file = File::create(path.join("head"))?;
94+
let file = File::create(path.join("head"))?;
9595
let mut snappy = snap::Writer::new(file);
9696

9797
let mut stream = RlpStream::new();
@@ -108,7 +108,7 @@ fn write_snapshot(db: Arc<KeyValueDB>, path: PathBuf, root: &H256) -> Result<(),
108108

109109
for (grandchild, _) in &grandchildren {
110110
let nodes = enumerate_subtree(&db, grandchild)?;
111-
let mut file = File::create(path.join(format!("{:x}", grandchild)))?;
111+
let file = File::create(path.join(format!("{:x}", grandchild)))?;
112112
let mut snappy = snap::Writer::new(file);
113113

114114
let mut stream = RlpStream::new();
@@ -119,7 +119,7 @@ fn write_snapshot(db: Arc<KeyValueDB>, path: PathBuf, root: &H256) -> Result<(),
119119
stream.append(&value);
120120
}
121121
stream.complete_unbounded_list();
122-
122+
123123
snappy.write(&stream.drain())?;
124124
}
125125

0 commit comments

Comments
 (0)