@@ -177,7 +177,7 @@ impl RuntimeCache {
177177
178178 /// Prepares a WASM module instance and executes given function for it.
179179 ///
180- /// This uses internal cache to find avaiable instance or create a new one.
180+ /// This uses internal cache to find available instance or create a new one.
181181 /// # Parameters
182182 ///
183183 /// `code` - Provides external code or tells the executor to fetch it from storage.
@@ -196,7 +196,7 @@ impl RuntimeCache {
196196 ///
197197 /// `f` - Function to execute.
198198 ///
199- /// # Returns result of `f` wrapped in an additonal result.
199+ /// # Returns result of `f` wrapped in an additional result.
200200 /// In case of failure one of two errors can be returned:
201201 ///
202202 /// `Err::InvalidCode` is returned for runtime code issues.
@@ -337,7 +337,7 @@ pub fn create_wasm_runtime_with_code(
337337 }
338338}
339339
340- fn decode_version ( version : & [ u8 ] ) -> Result < RuntimeVersion , WasmError > {
340+ fn decode_version ( mut version : & [ u8 ] ) -> Result < RuntimeVersion , WasmError > {
341341 let v: RuntimeVersion = sp_api:: OldRuntimeVersion :: decode ( & mut & version[ ..] )
342342 . map_err ( |_|
343343 WasmError :: Instantiation (
@@ -347,7 +347,7 @@ fn decode_version(version: &[u8]) -> Result<RuntimeVersion, WasmError> {
347347
348348 let core_api_id = sp_core:: hashing:: blake2_64 ( b"Core" ) ;
349349 if v. has_api_with ( & core_api_id, |v| v >= 3 ) {
350- sp_api:: RuntimeVersion :: decode ( & mut & version[ .. ] )
350+ sp_api:: RuntimeVersion :: decode ( & mut version)
351351 . map_err ( |_|
352352 WasmError :: Instantiation ( "failed to decode \" Core_version\" result" . into ( ) )
353353 )
@@ -367,9 +367,7 @@ fn decode_runtime_apis(apis: &[u8]) -> Result<Vec<([u8; 8], u32)>, WasmError> {
367367 <[ u8 ; RUNTIME_API_INFO_SIZE ] >:: try_from ( chunk)
368368 . map ( sp_api:: deserialize_runtime_api_info)
369369 . map_err ( |_| {
370- WasmError :: Other ( format ! (
371- "a clipped runtime api info declaration"
372- ) )
370+ WasmError :: Other ( "a clipped runtime api info declaration" . to_owned ( ) )
373371 } )
374372 } )
375373 . collect :: < Result < Vec < _ > , WasmError > > ( )
@@ -383,15 +381,15 @@ fn decode_runtime_apis(apis: &[u8]) -> Result<Vec<([u8; 8], u32)>, WasmError> {
383381pub fn read_embedded_version (
384382 blob : & RuntimeBlob ,
385383) -> Result < Option < RuntimeVersion > , WasmError > {
386- if let Some ( version_section) = blob. custom_section_contents ( "runtime_version" ) {
384+ if let Some ( mut version_section) = blob. custom_section_contents ( "runtime_version" ) {
387385 // We do not use `decode_version` here because the runtime_version section is not supposed
388386 // to ever contain a legacy version. Apart from that `decode_version` relies on presence
389387 // of a special API in the `apis` field to treat the input as a non-legacy version. However
390388 // the structure found in the `runtime_version` always contain an empty `apis` field. Therefore
391- // the version read will be mistakingly treated as an legacy one.
392- let mut decoded_version = sp_api:: RuntimeVersion :: decode ( & mut & version_section[ .. ] )
389+ // the version read will be mistakenly treated as an legacy one.
390+ let mut decoded_version = sp_api:: RuntimeVersion :: decode ( & mut version_section)
393391 . map_err ( |_|
394- WasmError :: Instantiation ( "failed to decode verison section" . into ( ) )
392+ WasmError :: Instantiation ( "failed to decode version section" . into ( ) )
395393 ) ?;
396394
397395 // Don't stop on this and check if there is a special section that encodes all runtime APIs.
0 commit comments