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

Commit

Permalink
Address @athei's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikbratashchuk committed Jan 21, 2022
1 parent 7e72790 commit 5066916
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub trait Ext: sealing::Sealed {
take_old: bool,
) -> Result<WriteOutcome, DispatchError>;

/// Sets new code hash for existing contract
/// Sets new code hash for existing contract.
fn set_code_hash(&mut self, hash: CodeHash<Self::T>) -> Result<(), DispatchError>;

/// Returns a reference to the account id of the caller.
Expand Down Expand Up @@ -1021,10 +1021,10 @@ where
}

fn set_code_hash(&mut self, hash: CodeHash<Self::T>) -> Result<(), DispatchError> {
let top_frame = &mut self.top_frame_mut();
increment_refcount::<Self::T>(hash)?;
let top_frame = self.top_frame_mut();
let prev_hash = top_frame.contract_info().code_hash.clone();
top_frame.contract_info().code_hash = hash;
increment_refcount::<Self::T>(hash)?;
decrement_refcount::<Self::T>(prev_hash)?;
Contracts::<Self::T>::deposit_event(Event::ContractCodeUpdated {
contract: top_frame.account_id.clone(),
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,11 @@ pub mod pallet {
/// A code with the specified hash was removed.
CodeRemoved { code_hash: T::Hash },

/// Contract code has been updated to one specified with code_hash
/// A contract code has changed its code.
ContractCodeUpdated {
/// The contract that has been updated.
contract: T::AccountId,
/// New code hash that was set for the contract
/// New code hash that was set for the contract.
code_hash: T::Hash,
},
}
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/wasm/code_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn decrement_refcount<T: Config>(code_hash: CodeHash<T>) -> Result<(), Dispa
///
/// # Errors
///
/// DispatchError::CannotLookup is returned if there is no info for specified code_hash
/// `Error::CodeNotFound` is returned if the specified `code_hash` does not exist.
pub fn increment_refcount<T: Config>(code_hash: CodeHash<T>) -> Result<(), DispatchError> {
<OwnerInfoOf<T>>::mutate(code_hash, |existing| -> Result<(), DispatchError> {
if let Some(info) = existing {
Expand Down

0 comments on commit 5066916

Please sign in to comment.