mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 12:25:51 +00:00
chore: remove duplicated arc (#13871)
This commit is contained in:
@@ -48,7 +48,7 @@ fn initialize(
|
|||||||
_tmpdir: &mut Option<tempfile::TempDir>,
|
_tmpdir: &mut Option<tempfile::TempDir>,
|
||||||
runtime: &[u8],
|
runtime: &[u8],
|
||||||
method: Method,
|
method: Method,
|
||||||
) -> Arc<dyn WasmModule> {
|
) -> Box<dyn WasmModule> {
|
||||||
let blob = RuntimeBlob::uncompress_if_needed(runtime).unwrap();
|
let blob = RuntimeBlob::uncompress_if_needed(runtime).unwrap();
|
||||||
let host_functions = sp_io::SubstrateHostFunctions::host_functions();
|
let host_functions = sp_io::SubstrateHostFunctions::host_functions();
|
||||||
let allow_missing_func_imports = true;
|
let allow_missing_func_imports = true;
|
||||||
@@ -60,7 +60,7 @@ fn initialize(
|
|||||||
host_functions,
|
host_functions,
|
||||||
allow_missing_func_imports,
|
allow_missing_func_imports,
|
||||||
)
|
)
|
||||||
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) }),
|
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) }),
|
||||||
Method::Compiled { instantiation_strategy, precompile } => {
|
Method::Compiled { instantiation_strategy, precompile } => {
|
||||||
let config = sc_executor_wasmtime::Config {
|
let config = sc_executor_wasmtime::Config {
|
||||||
allow_missing_func_imports,
|
allow_missing_func_imports,
|
||||||
@@ -98,7 +98,7 @@ fn initialize(
|
|||||||
} else {
|
} else {
|
||||||
sc_executor_wasmtime::create_runtime::<sp_io::SubstrateHostFunctions>(blob, config)
|
sc_executor_wasmtime::create_runtime::<sp_io::SubstrateHostFunctions>(blob, config)
|
||||||
}
|
}
|
||||||
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) })
|
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) })
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ where
|
|||||||
) -> Result<R>
|
) -> Result<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(
|
F: FnOnce(
|
||||||
AssertUnwindSafe<&Arc<dyn WasmModule>>,
|
AssertUnwindSafe<&dyn WasmModule>,
|
||||||
AssertUnwindSafe<&mut dyn WasmInstance>,
|
AssertUnwindSafe<&mut dyn WasmInstance>,
|
||||||
Option<&RuntimeVersion>,
|
Option<&RuntimeVersion>,
|
||||||
AssertUnwindSafe<&mut dyn Externalities>,
|
AssertUnwindSafe<&mut dyn Externalities>,
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ fn should_trap_when_heap_exhausted(wasm_method: WasmExecutionMethod) {
|
|||||||
fn mk_test_runtime(
|
fn mk_test_runtime(
|
||||||
wasm_method: WasmExecutionMethod,
|
wasm_method: WasmExecutionMethod,
|
||||||
pages: HeapAllocStrategy,
|
pages: HeapAllocStrategy,
|
||||||
) -> Arc<dyn WasmModule> {
|
) -> Box<dyn WasmModule> {
|
||||||
let blob = RuntimeBlob::uncompress_if_needed(wasm_binary_unwrap())
|
let blob = RuntimeBlob::uncompress_if_needed(wasm_binary_unwrap())
|
||||||
.expect("failed to create a runtime blob out of test runtime");
|
.expect("failed to create a runtime blob out of test runtime");
|
||||||
|
|
||||||
|
|||||||
@@ -71,14 +71,14 @@ struct VersionedRuntimeId {
|
|||||||
/// A Wasm runtime object along with its cached runtime version.
|
/// A Wasm runtime object along with its cached runtime version.
|
||||||
struct VersionedRuntime {
|
struct VersionedRuntime {
|
||||||
/// Shared runtime that can spawn instances.
|
/// Shared runtime that can spawn instances.
|
||||||
module: Arc<dyn WasmModule>,
|
module: Box<dyn WasmModule>,
|
||||||
/// Runtime version according to `Core_version` if any.
|
/// Runtime version according to `Core_version` if any.
|
||||||
version: Option<RuntimeVersion>,
|
version: Option<RuntimeVersion>,
|
||||||
|
|
||||||
// TODO: Remove this once the legacy instance reuse instantiation strategy
|
// TODO: Remove this once the legacy instance reuse instantiation strategy
|
||||||
// for `wasmtime` is gone, as this only makes sense with that particular strategy.
|
// for `wasmtime` is gone, as this only makes sense with that particular strategy.
|
||||||
/// Cached instance pool.
|
/// Cached instance pool.
|
||||||
instances: Arc<Vec<Mutex<Option<Box<dyn WasmInstance>>>>>,
|
instances: Vec<Mutex<Option<Box<dyn WasmInstance>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VersionedRuntime {
|
impl VersionedRuntime {
|
||||||
@@ -86,7 +86,7 @@ impl VersionedRuntime {
|
|||||||
fn with_instance<R, F>(&self, ext: &mut dyn Externalities, f: F) -> Result<R, Error>
|
fn with_instance<R, F>(&self, ext: &mut dyn Externalities, f: F) -> Result<R, Error>
|
||||||
where
|
where
|
||||||
F: FnOnce(
|
F: FnOnce(
|
||||||
&Arc<dyn WasmModule>,
|
&dyn WasmModule,
|
||||||
&mut dyn WasmInstance,
|
&mut dyn WasmInstance,
|
||||||
Option<&RuntimeVersion>,
|
Option<&RuntimeVersion>,
|
||||||
&mut dyn Externalities,
|
&mut dyn Externalities,
|
||||||
@@ -106,7 +106,7 @@ impl VersionedRuntime {
|
|||||||
.map(|r| Ok((r, false)))
|
.map(|r| Ok((r, false)))
|
||||||
.unwrap_or_else(|| self.module.new_instance().map(|i| (i, true)))?;
|
.unwrap_or_else(|| self.module.new_instance().map(|i| (i, true)))?;
|
||||||
|
|
||||||
let result = f(&self.module, &mut *instance, self.version.as_ref(), ext);
|
let result = f(&*self.module, &mut *instance, self.version.as_ref(), ext);
|
||||||
if let Err(e) = &result {
|
if let Err(e) = &result {
|
||||||
if new_inst {
|
if new_inst {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
@@ -142,7 +142,7 @@ impl VersionedRuntime {
|
|||||||
// Allocate a new instance
|
// Allocate a new instance
|
||||||
let mut instance = self.module.new_instance()?;
|
let mut instance = self.module.new_instance()?;
|
||||||
|
|
||||||
f(&self.module, &mut *instance, self.version.as_ref(), ext)
|
f(&*self.module, &mut *instance, self.version.as_ref(), ext)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ impl RuntimeCache {
|
|||||||
where
|
where
|
||||||
H: HostFunctions,
|
H: HostFunctions,
|
||||||
F: FnOnce(
|
F: FnOnce(
|
||||||
&Arc<dyn WasmModule>,
|
&dyn WasmModule,
|
||||||
&mut dyn WasmInstance,
|
&mut dyn WasmInstance,
|
||||||
Option<&RuntimeVersion>,
|
Option<&RuntimeVersion>,
|
||||||
&mut dyn Externalities,
|
&mut dyn Externalities,
|
||||||
@@ -294,7 +294,7 @@ pub fn create_wasm_runtime_with_code<H>(
|
|||||||
blob: RuntimeBlob,
|
blob: RuntimeBlob,
|
||||||
allow_missing_func_imports: bool,
|
allow_missing_func_imports: bool,
|
||||||
cache_path: Option<&Path>,
|
cache_path: Option<&Path>,
|
||||||
) -> Result<Arc<dyn WasmModule>, WasmError>
|
) -> Result<Box<dyn WasmModule>, WasmError>
|
||||||
where
|
where
|
||||||
H: HostFunctions,
|
H: HostFunctions,
|
||||||
{
|
{
|
||||||
@@ -312,7 +312,7 @@ where
|
|||||||
H::host_functions(),
|
H::host_functions(),
|
||||||
allow_missing_func_imports,
|
allow_missing_func_imports,
|
||||||
)
|
)
|
||||||
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) })
|
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) })
|
||||||
},
|
},
|
||||||
WasmExecutionMethod::Compiled { instantiation_strategy } =>
|
WasmExecutionMethod::Compiled { instantiation_strategy } =>
|
||||||
sc_executor_wasmtime::create_runtime::<H>(
|
sc_executor_wasmtime::create_runtime::<H>(
|
||||||
@@ -333,7 +333,7 @@ where
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) }),
|
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ where
|
|||||||
let mut instances = Vec::with_capacity(max_instances);
|
let mut instances = Vec::with_capacity(max_instances);
|
||||||
instances.resize_with(max_instances, || Mutex::new(None));
|
instances.resize_with(max_instances, || Mutex::new(None));
|
||||||
|
|
||||||
Ok(VersionedRuntime { module: runtime, version, instances: Arc::new(instances) })
|
Ok(VersionedRuntime { module: runtime, version, instances })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user