github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/config/execution_config.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package config 5 6 import ( 7 "encoding/json" 8 "time" 9 10 "github.com/MetalBlockchain/metalgo/utils/units" 11 "github.com/MetalBlockchain/metalgo/vms/platformvm/network" 12 ) 13 14 var DefaultExecutionConfig = ExecutionConfig{ 15 Network: network.DefaultConfig, 16 BlockCacheSize: 64 * units.MiB, 17 TxCacheSize: 128 * units.MiB, 18 TransformedSubnetTxCacheSize: 4 * units.MiB, 19 RewardUTXOsCacheSize: 2048, 20 ChainCacheSize: 2048, 21 ChainDBCacheSize: 2048, 22 BlockIDCacheSize: 8192, 23 FxOwnerCacheSize: 4 * units.MiB, 24 ChecksumsEnabled: false, 25 MempoolPruneFrequency: 30 * time.Minute, 26 } 27 28 // ExecutionConfig provides execution parameters of PlatformVM 29 type ExecutionConfig struct { 30 Network network.Config `json:"network"` 31 BlockCacheSize int `json:"block-cache-size"` 32 TxCacheSize int `json:"tx-cache-size"` 33 TransformedSubnetTxCacheSize int `json:"transformed-subnet-tx-cache-size"` 34 RewardUTXOsCacheSize int `json:"reward-utxos-cache-size"` 35 ChainCacheSize int `json:"chain-cache-size"` 36 ChainDBCacheSize int `json:"chain-db-cache-size"` 37 BlockIDCacheSize int `json:"block-id-cache-size"` 38 FxOwnerCacheSize int `json:"fx-owner-cache-size"` 39 ChecksumsEnabled bool `json:"checksums-enabled"` 40 MempoolPruneFrequency time.Duration `json:"mempool-prune-frequency"` 41 } 42 43 // GetExecutionConfig returns an ExecutionConfig 44 // input is unmarshalled into an ExecutionConfig previously 45 // initialized with default values 46 func GetExecutionConfig(b []byte) (*ExecutionConfig, error) { 47 ec := DefaultExecutionConfig 48 49 // if bytes are empty keep default values 50 if len(b) == 0 { 51 return &ec, nil 52 } 53 54 return &ec, json.Unmarshal(b, &ec) 55 }