github.com/ava-labs/avalanchego@v1.11.11/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/ava-labs/avalanchego/utils/units" 11 "github.com/ava-labs/avalanchego/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 SubnetManagerCacheSize: 4 * units.MiB, 25 ChecksumsEnabled: false, 26 MempoolPruneFrequency: 30 * time.Minute, 27 } 28 29 // ExecutionConfig provides execution parameters of PlatformVM 30 type ExecutionConfig struct { 31 Network network.Config `json:"network"` 32 BlockCacheSize int `json:"block-cache-size"` 33 TxCacheSize int `json:"tx-cache-size"` 34 TransformedSubnetTxCacheSize int `json:"transformed-subnet-tx-cache-size"` 35 RewardUTXOsCacheSize int `json:"reward-utxos-cache-size"` 36 ChainCacheSize int `json:"chain-cache-size"` 37 ChainDBCacheSize int `json:"chain-db-cache-size"` 38 BlockIDCacheSize int `json:"block-id-cache-size"` 39 FxOwnerCacheSize int `json:"fx-owner-cache-size"` 40 SubnetManagerCacheSize int `json:"subnet-manager-cache-size"` 41 ChecksumsEnabled bool `json:"checksums-enabled"` 42 MempoolPruneFrequency time.Duration `json:"mempool-prune-frequency"` 43 } 44 45 // GetExecutionConfig returns an ExecutionConfig 46 // input is unmarshalled into an ExecutionConfig previously 47 // initialized with default values 48 func GetExecutionConfig(b []byte) (*ExecutionConfig, error) { 49 ec := DefaultExecutionConfig 50 51 // if bytes are empty keep default values 52 if len(b) == 0 { 53 return &ec, nil 54 } 55 56 return &ec, json.Unmarshal(b, &ec) 57 }