cleaning up substate

This commit is contained in:
debris 2016-07-21 16:50:24 +02:00
parent 77babe6226
commit a1857bf139
3 changed files with 5 additions and 19 deletions

View File

@ -433,7 +433,7 @@ impl<'a> Executive<'a> {
self.state.add_balance(&self.info.author, &fees_value); self.state.add_balance(&self.info.author, &fees_value);
// perform suicides // perform suicides
for (address, _) in &substate.suicides { for address in &substate.suicides {
self.state.kill_account(address); self.state.kill_account(address);
} }

View File

@ -263,12 +263,7 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
self.state.transfer_balance(&address, refund_address, &balance); self.state.transfer_balance(&address, refund_address, &balance);
} }
let details = SuicideDetails { self.substate.suicides.insert(address);
refund_address: refund_address.clone(),
value: balance,
};
self.substate.suicides.insert(address, details);
} }
fn schedule(&self) -> &Schedule { fn schedule(&self) -> &Schedule {

View File

@ -15,25 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Execution environment substate. //! Execution environment substate.
use std::collections::HashMap; use std::collections::HashSet;
use util::{Address, U256}; use util::{Address, U256};
use log_entry::LogEntry; use log_entry::LogEntry;
/// Details of the commited suicide.
#[derive(Debug, Default)]
pub struct SuicideDetails {
/// Suicided contract heir.
pub refund_address: Address,
/// Balance of the contract just before suicide.
pub value: U256,
}
/// State changes which should be applied in finalize, /// State changes which should be applied in finalize,
/// after transaction is fully executed. /// after transaction is fully executed.
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct Substate { pub struct Substate {
/// Any accounts that have suicided. /// Any accounts that have suicided.
pub suicides: HashMap<Address, SuicideDetails>, pub suicides: HashSet<Address>,
/// Any logs. /// Any logs.
pub logs: Vec<LogEntry>, pub logs: Vec<LogEntry>,
@ -81,7 +72,7 @@ mod tests {
data: vec![] data: vec![]
}); });
sub_state.sstore_clears_count = 5.into(); sub_state.sstore_clears_count = 5.into();
sub_state.suicides.insert(10u64.into(), Default::default()); sub_state.suicides.insert(10u64.into());
let mut sub_state_2 = Substate::new(); let mut sub_state_2 = Substate::new();
sub_state_2.contracts_created.push(2u64.into()); sub_state_2.contracts_created.push(2u64.into());