@@ -30,7 +30,6 @@ type VM struct {
30
30
// `cacheSize` sets the size in MiB of an in-memory cache for e.g. module caching. Set to 0 to disable.
31
31
// `deserCost` sets the gas cost of deserializing one byte of data.
32
32
func NewVM (dataDir string , supportedCapabilities []string , memoryLimit uint32 , printDebug bool , cacheSize uint32 ) (* VM , error ) {
33
- // TODO: expose config variant of NewVM
34
33
cache , err := api .InitCache (types.VMConfig {
35
34
Cache : types.CacheOptions {
36
35
BaseDir : dataDir ,
@@ -45,6 +44,17 @@ func NewVM(dataDir string, supportedCapabilities []string, memoryLimit uint32, p
45
44
return & VM {cache : cache , printDebug : printDebug }, nil
46
45
}
47
46
47
+ // NewVMWithConfig creates a new VM with a custom configuration.
48
+ // This allows for more fine-grained control over the VM's behavior compared to NewVM and
49
+ // can be extended more easily in the future.
50
+ func NewVMWithConfig (config types.VMConfig , printDebug bool ) (* VM , error ) {
51
+ cache , err := api .InitCache (config )
52
+ if err != nil {
53
+ return nil , err
54
+ }
55
+ return & VM {cache : cache , printDebug : printDebug }, nil
56
+ }
57
+
48
58
// Cleanup should be called when no longer using this instances.
49
59
// It frees resources in libwasmvm (the Rust part) and releases a lock in the base directory.
50
60
func (vm * VM ) Cleanup () {
0 commit comments