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

Commit

Permalink
Minor alterations
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Jun 23, 2017
1 parent 0399550 commit d80bc2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl AccountEntry {
self.state == AccountState::Dirty
}

fn is_null(&self) -> bool {
fn exists_and_is_null(&self) -> bool {
self.account.as_ref().map_or(false, |a| a.is_null())
}

Expand Down Expand Up @@ -573,7 +573,7 @@ impl<B: Backend> State<B> {
/// Subtract `decr` from the balance of account `a`.
pub fn sub_balance(&mut self, a: &Address, decr: &U256, cleanup_mode: &mut CleanupMode) -> trie::Result<()> {
trace!(target: "state", "sub_balance({}, {}): {}", a, decr, self.balance(a)?);
if !decr.is_zero() {
if !decr.is_zero() || !self.exists(a)? {
self.require(a, false)?.sub_balance(decr);
}
if let CleanupMode::TrackTouched(ref mut set) = *cleanup_mode {
Expand Down Expand Up @@ -712,8 +712,8 @@ impl<B: Backend> State<B> {
pub fn kill_garbage(&mut self, touched: &HashSet<Address>, remove_empty_touched: bool, min_balance: &Option<U256>, kill_contracts: bool) -> trie::Result<()> {
let to_kill: HashSet<_> = {
self.cache.borrow().iter().filter_map(|(address, ref entry)|
if touched.contains(address) && // Check any modified accounts and 0x3 additionally.
((remove_empty_touched && entry.is_null()) // Remove all empty touched accounts.
if touched.contains(address) && // Check all touched accounts
((remove_empty_touched && entry.exists_and_is_null()) // Remove all empty touched accounts.
|| min_balance.map_or(false, |ref balance| entry.account.as_ref().map_or(false, |account|
(account.is_basic() || kill_contracts) // Remove all basic and optionally contract accounts where balance has been decreased.
&& account.balance() < balance && entry.old_balance.as_ref().map_or(false, |b| account.balance() < b)))) {
Expand Down

0 comments on commit d80bc2f

Please sign in to comment.