This commit is contained in:
arkpar 2016-02-05 02:08:17 +01:00
parent 755ee95326
commit a87edc2557
2 changed files with 5 additions and 3 deletions

View File

@ -62,6 +62,7 @@ impl State {
self.snapshots.borrow_mut().push(HashMap::new());
}
/// Merge last snapshot with previous
pub fn clear_snapshot(&mut self) {
// merge with previous snapshot
let last = self.snapshots.borrow_mut().pop();
@ -74,6 +75,7 @@ impl State {
}
}
/// Revert to snapshot
pub fn revert_snapshot(&mut self) {
if let Some(mut snapshot) = self.snapshots.borrow_mut().pop() {
for (k, v) in snapshot.drain() {
@ -89,7 +91,6 @@ impl State {
}
}
fn insert_cache(&self, address: &Address, account: Option<Account>) {
if let Some(ref mut snapshot) = self.snapshots.borrow_mut().last_mut() {
if !snapshot.contains_key(&address) {

View File

@ -130,9 +130,10 @@ impl JournalDB {
last = r.drain();
&last
})) {
let to_add;
let rlp = Rlp::new(&rlp_data);
{
let to_add: Vec<H256> = rlp.val_at(1);
to_add = rlp.val_at(1);
for i in &to_add {
let delete_counter = {
if let Some(mut cnt) = counters.get_mut(i) {
@ -147,7 +148,7 @@ impl JournalDB {
}
}
}
let to_remove: Vec<H256> = rlp.val_at(if canon_id == rlp.val_at(0) {2} else {1});
let to_remove: Vec<H256> = if canon_id == rlp.val_at(0) {rlp.val_at(2)} else {to_add};
for i in &to_remove {
if !counters.contains_key(i) {
batch.delete(&i).expect("Low-level database error. Some issue with your hard disk?");