Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Remove cruft.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Dec 19, 2015
1 parent b922f8d commit 4c58d1a
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use util::overlaydb::*;
use util::trie::*;
use util::rlp::*;
use util::uint::*;
use std::mem;
//use std::cell::*;
//use std::ops::*;
use account::Account;
Expand Down Expand Up @@ -82,15 +81,9 @@ impl State {
&self.root
}

/// Desttroy the current database and return it.
/// WARNING: the struct should be dropped immediately following this.
pub fn take_db(&mut self) -> OverlayDB {
mem::replace(&mut self.db, OverlayDB::new_temp())
}

/// Destroy the current object and return root and database.
pub fn drop(mut self) -> (H256, OverlayDB) {
(mem::replace(&mut self.root, H256::new()), mem::replace(&mut self.db, OverlayDB::new_temp()))
pub fn drop(self) -> (H256, OverlayDB) {
(self.root, self.db)
}

/// Expose the underlying database; good to use for calling `state.db().commit()`.
Expand Down Expand Up @@ -258,7 +251,7 @@ fn code_from_database() {
assert_eq!(s.code(&a), Some(&[1u8, 2, 3][..]));
s.commit();
assert_eq!(s.code(&a), Some(&[1u8, 2, 3][..]));
(s.root().clone(), s.take_db())
s.drop()
};

let mut s = State::new_existing(db, r, U256::from(0u8));
Expand All @@ -272,7 +265,7 @@ fn storage_at_from_database() {
let mut s = State::new_temp();
s.set_storage(&a, H256::from(&U256::from(01u64)), H256::from(&U256::from(69u64)));
s.commit();
(s.root().clone(), s.take_db())
s.drop()
};

let mut s = State::new_existing(db, r, U256::from(0u8));
Expand All @@ -288,7 +281,7 @@ fn get_from_database() {
s.add_balance(&a, &U256::from(69u64));
s.commit();
assert_eq!(s.balance(&a), U256::from(69u64));
(s.root().clone(), s.take_db())
s.drop()
};

let mut s = State::new_existing(db, r, U256::from(0u8));
Expand Down

0 comments on commit 4c58d1a

Please sign in to comment.