core/vm: tweak the --vm.ewasm= option format

This commit is contained in:
Guillaume Ballet 2018-10-11 15:06:49 +02:00
parent f951e23fb5
commit 92f20ec18a
2 changed files with 15 additions and 2 deletions

View file

@ -43,7 +43,7 @@ type Config struct {
JumpTable [256]operation JumpTable [256]operation
// Type of the EWASM interpreter // Type of the EWASM interpreter
EWASMInterpreter string EWASMInterpreter map[string]string
// Type of the EVM interpreter // Type of the EVM interpreter
EVMInterpreter string EVMInterpreter string
} }

View file

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"runtime" "runtime"
"strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -148,10 +149,22 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
} }
rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion) rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion)
} }
ewasmOptions := make(map[string]string)
if len(config.EWASMInterpreter) > 0 {
for _, option := range strings.Split(config.EWASMInterpreter, ",") {
opt := strings.Split(option, ":")
if len(opt) != 2 || len(opt[0]) == 0 {
panic(fmt.Sprintf("Invalid ewasm option: expected a format of name:value, got: %s", option))
}
ewasmOptions[opt[0]] = opt[1]
}
}
var ( var (
vmConfig = vm.Config{ vmConfig = vm.Config{
EnablePreimageRecording: config.EnablePreimageRecording, EnablePreimageRecording: config.EnablePreimageRecording,
EWASMInterpreter: config.EWASMInterpreter, EWASMInterpreter: ewasmOptions,
EVMInterpreter: config.EVMInterpreter, EVMInterpreter: config.EVMInterpreter,
} }
cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout}