pub fn load<T: Trait>(
	code_hash: &HashFor<T>,
	schedule: &Schedule,
) -> Result<PrefabWasmModule, &'static str> {
	let mut prefab_module =
		<CodeStorage<T>>::get(code_hash).ok_or_else(|| "code is not found")?;

	if prefab_module.schedule_version < schedule.version {
		// The current schedule version is greater than the version of the one cached
		// in the storage.
		//
		// We need to re-instrument the code with the latest schedule here.
		let original_code =
			<PristineCode<T>>::get(code_hash).ok_or_else(|| "pristine code is not found")?;
		prefab_module = prepare::prepare_contract::<Env>(&original_code, schedule)?;
		<CodeStorage<T>>::insert(&code_hash, &prefab_module);
	}
	Ok(prefab_module)
}
/// Load code with the given code hash.
///
/// If the module was instrumented with a lower version of schedule than
/// the current one given as an argument, then this function will perform
/// re-instrumentation and update the cache in the storage.
Load code with the given code hash.
If the module was instrumented with a lower version of schedule than
the current one given as an argument, then this function will perform
re-instrumentation and update the cache in the storage.
Load code with the given code hash . If the module was instrumented with a lower version of schedule than the current one given as an argument then this function will perform re - instrumentation and update the cache in the storage .
pub fn load<T: Trait>(
	code_hash: &HashFor<T>,
	schedule: &Schedule,
) -> Result<PrefabWasmModule, &'static str> {
	let mut prefab_module =
		<CodeStorage<T>>::get(code_hash).ok_or_else(|| "code is not found")?;
	if prefab_module.schedule_version < schedule.version {
		// The current schedule version is greater than the version of the one cached
		// in the storage.
		//
		// We need to re-instrument the code with the latest schedule here.
		let original_code =
			<PristineCode<T>>::get(code_hash).ok_or_else(|| "pristine code is not found")?;
		prefab_module = prepare::prepare_contract::<Env>(&original_code, schedule)?;
		<CodeStorage<T>>::insert(&code_hash, &prefab_module);
	}
	Ok(prefab_module)
}
pub fn load < T : Trait > ( code_hash : & HashFor < T > , schedule : & Schedule , ) -> Result < PrefabWasmModule , & ' static str > { let mut prefab_module = < CodeStorage < T > > :: get ( code_hash ) . ok_or_else ( | | " " ) ? ; if prefab_module . schedule_version < schedule . version { // The current schedule version is greater than the version of the one cached // in the storage. // // We need to re-instrument the code with the latest schedule here. let original_code = < PristineCode < T > > :: get ( code_hash ) . ok_or_else ( | | " " ) ? ; prefab_module = prepare :: prepare_contract :: < Env > ( & original_code , schedule ) ? ; < CodeStorage < T > > :: insert ( & code_hash , & prefab_module ) ; } Ok ( prefab_module ) }
Load code with the given code hash.
Load code with the given code hash .
code_hash
&HashFor<T>
schedule
&Schedule
code_hash
&HashFor<T>
schedule
&Schedule