Skip to content

Commit

Permalink
Rename init_cache argument to available_capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Sep 1, 2022
1 parent 2255970 commit 46bc611
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libwasmvm/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ typedef struct GoQuerier {
} GoQuerier;

struct cache_t *init_cache(struct ByteSliceView data_dir,
struct ByteSliceView supported_features,
struct ByteSliceView available_capabilities,
uint32_t cache_size,
uint32_t instance_memory_limit,
struct UnmanagedVector *error_msg);
Expand Down
2 changes: 1 addition & 1 deletion libwasmvm/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// store some common string for argument names
pub const DATA_DIR_ARG: &str = "data_dir";
pub const FEATURES_ARG: &str = "supported_features";
pub const AVAILABLE_CAPABILITIES_ARG: &str = "available_capabilities";
pub const CACHE_ARG: &str = "cache";
pub const WASM_ARG: &str = "wasm";
pub const CHECKSUM_ARG: &str = "checksum";
Expand Down
12 changes: 6 additions & 6 deletions libwasmvm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::str::from_utf8;
use cosmwasm_vm::{capabilities_from_csv, Cache, CacheOptions, Checksum, Size};

use crate::api::GoApi;
use crate::args::{CACHE_ARG, CHECKSUM_ARG, DATA_DIR_ARG, FEATURES_ARG, WASM_ARG};
use crate::args::{AVAILABLE_CAPABILITIES_ARG, CACHE_ARG, CHECKSUM_ARG, DATA_DIR_ARG, WASM_ARG};
use crate::error::{handle_c_error_binary, handle_c_error_default, handle_c_error_ptr, Error};
use crate::memory::{ByteSliceView, UnmanagedVector};
use crate::querier::GoQuerier;
Expand All @@ -27,15 +27,15 @@ pub fn to_cache(ptr: *mut cache_t) -> Option<&'static mut Cache<GoApi, GoStorage
#[no_mangle]
pub extern "C" fn init_cache(
data_dir: ByteSliceView,
supported_features: ByteSliceView,
available_capabilities: ByteSliceView,
cache_size: u32, // in MiB
instance_memory_limit: u32, // in MiB
error_msg: Option<&mut UnmanagedVector>,
) -> *mut cache_t {
let r = catch_unwind(|| {
do_init_cache(
data_dir,
supported_features,
available_capabilities,
cache_size,
instance_memory_limit,
)
Expand All @@ -46,7 +46,7 @@ pub extern "C" fn init_cache(

fn do_init_cache(
data_dir: ByteSliceView,
supported_capabilities: ByteSliceView,
available_capabilities: ByteSliceView,
cache_size: u32, // in MiB
instance_memory_limit: u32, // in MiB
) -> Result<*mut Cache<GoApi, GoStorage, GoQuerier>, Error> {
Expand All @@ -55,9 +55,9 @@ fn do_init_cache(
.ok_or_else(|| Error::unset_arg(DATA_DIR_ARG))?;
let dir_str = String::from_utf8(dir.to_vec())?;
// parse the supported features
let capabilities_bin = supported_capabilities
let capabilities_bin = available_capabilities
.read()
.ok_or_else(|| Error::unset_arg(FEATURES_ARG))?;
.ok_or_else(|| Error::unset_arg(AVAILABLE_CAPABILITIES_ARG))?;
let capabilities = capabilities_from_csv(from_utf8(capabilities_bin)?);
let memory_cache_size = Size::mebi(
cache_size
Expand Down

0 comments on commit 46bc611

Please sign in to comment.