@@ -228,23 +228,29 @@ where
228228 ///
229229 /// This does the same as [`save_wasm_unchecked`] plus the static checks.
230230 /// When a Wasm blob is stored the first time, use this function.
231+ #[ deprecated = "Use `store_code` instead" ]
231232 pub fn save_wasm ( & self , wasm : & [ u8 ] ) -> VmResult < Checksum > {
232- self . store_code ( wasm, true )
233+ self . store_code ( wasm, true , true )
233234 }
234235
235236 /// Takes a Wasm bytecode and stores it to the cache.
236237 ///
237- /// This performs static checks, compiles the bytescode to a module and
238+ /// This performs static checks if `checked` is `true`,
239+ /// compiles the bytescode to a module and
238240 /// stores the Wasm file on disk if `persist` is `true`.
239241 ///
240- /// This does the same as [`save_wasm`] if `persist` is `true`.
241- pub fn store_code ( & self , wasm : & [ u8 ] , persist : bool ) -> VmResult < Checksum > {
242- check_wasm (
243- wasm,
244- & self . available_capabilities ,
245- & self . wasm_limits ,
246- crate :: internals:: Logger :: Off ,
247- ) ?;
242+ /// This does the same as [`save_wasm`] but without the static checks.
243+ /// When a Wasm blob is stored which was previously checked (e.g. as part of state sync),
244+ /// use this function.
245+ pub fn store_code ( & self , wasm : & [ u8 ] , checked : bool , persist : bool ) -> VmResult < Checksum > {
246+ if checked {
247+ check_wasm (
248+ wasm,
249+ & self . available_capabilities ,
250+ & self . wasm_limits ,
251+ crate :: internals:: Logger :: Off ,
252+ ) ?;
253+ }
248254
249255 let module = compile_module ( wasm) ?;
250256
@@ -263,9 +269,9 @@ where
263269 /// This does the same as [`save_wasm`] but without the static checks.
264270 /// When a Wasm blob is stored which was previously checked (e.g. as part of state sync),
265271 /// use this function.
272+ #[ deprecated = "Use `store_code` instead" ]
266273 pub fn save_wasm_unchecked ( & self , wasm : & [ u8 ] ) -> VmResult < Checksum > {
267- let module = compile_module ( wasm) ?;
268- self . save_to_disk ( wasm, & module)
274+ self . store_code ( wasm, false , true )
269275 }
270276
271277 fn save_to_disk ( & self , wasm : & [ u8 ] , module : & Module ) -> VmResult < Checksum > {
0 commit comments