Skip to content

Commit

Permalink
use existing utils to instantiate runtime code.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Oct 20, 2021
1 parent d8a9b50 commit 898bc13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions client/service/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,12 +1281,7 @@ where
if let Some(wasm) = storage.top.get(well_known_keys::CODE) {
let mut ext = sp_state_machine::BasicExternalities::new_empty(); // just to read runtime version.
let code_fetcher = crate::client::wasm_override::WasmBlob::new(wasm.clone());
let hash = code_fetcher.hash.clone();
let runtime_code = sp_core::traits::RuntimeCode {
code_fetcher: &code_fetcher,
heap_pages: None,
hash,
};
let runtime_code = code_fetcher.runtime_code(None);
let runtime_version =
RuntimeVersionOf::runtime_version(executor, &mut ext, &runtime_code)
.map_err(|e| sp_blockchain::Error::VersionInvalid(format!("{:?}", e)))?;
Expand Down
4 changes: 2 additions & 2 deletions client/service/src/client/wasm_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use std::{
/// Auxiliary structure that holds a wasm blob and its hash.
pub(crate) struct WasmBlob {
code: Vec<u8>,
pub(crate) hash: Vec<u8>,
hash: Vec<u8>,
}

impl WasmBlob {
Expand All @@ -60,7 +60,7 @@ impl WasmBlob {
Self { code, hash }
}

fn runtime_code(&self, heap_pages: Option<u64>) -> RuntimeCode {
pub(crate) fn runtime_code(&self, heap_pages: Option<u64>) -> RuntimeCode {
RuntimeCode { code_fetcher: self, hash: self.hash.clone(), heap_pages }
}
}
Expand Down

0 comments on commit 898bc13

Please sign in to comment.