From 898bc134a4a2936514c2e92b4474945b0cbf1566 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 20 Oct 2021 16:55:59 +0200 Subject: [PATCH] use existing utils to instantiate runtime code. --- client/service/src/client/client.rs | 7 +------ client/service/src/client/wasm_override.rs | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index 1127d31d6a053..fa03a6fa289ba 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -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)))?; diff --git a/client/service/src/client/wasm_override.rs b/client/service/src/client/wasm_override.rs index ee7ebb81078f2..2460b664b61cb 100644 --- a/client/service/src/client/wasm_override.rs +++ b/client/service/src/client/wasm_override.rs @@ -51,7 +51,7 @@ use std::{ /// Auxiliary structure that holds a wasm blob and its hash. pub(crate) struct WasmBlob { code: Vec, - pub(crate) hash: Vec, + hash: Vec, } impl WasmBlob { @@ -60,7 +60,7 @@ impl WasmBlob { Self { code, hash } } - fn runtime_code(&self, heap_pages: Option) -> RuntimeCode { + pub(crate) fn runtime_code(&self, heap_pages: Option) -> RuntimeCode { RuntimeCode { code_fetcher: self, hash: self.hash.clone(), heap_pages } } }