Skip to content

Commit

Permalink
VM default via feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
olonho committed Jun 22, 2020
1 parent b64bafb commit 0fef4a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 12 additions & 9 deletions runtime/near-vm-logic/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::types::Gas;
use serde::{Deserialize, Serialize};
use std::collections::hash_map::DefaultHasher;
use std::env;
use std::hash::{Hash, Hasher};

#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
Expand All @@ -13,15 +12,19 @@ pub enum VMKind {
}

impl Default for VMKind {
#[cfg(feature = "wasmer_default")]
fn default() -> Self {
match env::var("NEAR_VM") {
Ok(val) => match val.as_ref() {
"wasmtime" => VMKind::Wasmtime,
"wasmer" => VMKind::Wasmer,
_ => VMKind::Wasmer,
},
Err(_) => VMKind::Wasmer,
}
VMKind::Wasmer
}

#[cfg(feature = "wasmtime_default")]
fn default() -> Self {
VMKind::Wasmtime
}

#[cfg(all(not(feature = "wasmer_default"), not(feature = "wasmtime_default")))]
fn default() -> Self {
VMKind::Wasmer
}
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/near-vm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ wabt = "0.9"
bencher = "^0.1.5"

[features]
default = []
default = ["wasmer_default"]
wasmer_default = []
wasmtime_default = []

# Use this feature to enable counting of fees and costs applied.
costs_counting = ["near-vm-logic/costs_counting"]
Expand Down

0 comments on commit 0fef4a1

Please sign in to comment.