srml-contracts: Refactor away some duplication in runtime functions. (#3257)

* srml-contracts: Storage access micro-optimization.

* srml-contracts: Refactor runtime functions to reduce duplication.

* Bump node runtime impl version.
This commit is contained in:
Jim Posen
2019-08-08 15:02:04 +02:00
committed by Gavin Wood
parent 7c1fc4cc77
commit 0067b2d9a2
3 changed files with 41 additions and 58 deletions
+2 -3
View File
@@ -528,10 +528,10 @@ decl_module! {
code: Vec<u8>
) -> Result {
let origin = ensure_signed(origin)?;
let schedule = <Module<T>>::current_schedule();
let (mut gas_meter, imbalance) = gas::buy_gas::<T>(&origin, gas_limit)?;
let schedule = <Module<T>>::current_schedule();
let result = wasm::save_code::<T>(code, &mut gas_meter, &schedule);
if let Ok(code_hash) = result {
Self::deposit_event(RawEvent::CodeStored(code_hash));
@@ -812,10 +812,9 @@ decl_storage! {
impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
fn on_free_balance_zero(who: &T::AccountId) {
if let Some(ContractInfo::Alive(info)) = <ContractInfoOf<T>>::get(who) {
if let Some(ContractInfo::Alive(info)) = <ContractInfoOf<T>>::take(who) {
child::kill_storage(&info.trie_id);
}
<ContractInfoOf<T>>::remove(who);
}
}