github.com/prysmaticlabs/prysm@v1.4.4/shared/params/config_utils_develop.go (about)

     1  // +build develop
     2  
     3  package params
     4  
     5  import (
     6  	"sync"
     7  
     8  	"github.com/mohae/deepcopy"
     9  )
    10  
    11  var beaconConfig = MainnetConfig()
    12  var beaconConfigLock sync.RWMutex
    13  
    14  // BeaconConfig retrieves beacon chain config.
    15  func BeaconConfig() *BeaconChainConfig {
    16  	beaconConfigLock.RLock()
    17  	defer beaconConfigLock.RUnlock()
    18  	return beaconConfig
    19  }
    20  
    21  // OverrideBeaconConfig by replacing the config. The preferred pattern is to
    22  // call BeaconConfig(), change the specific parameters, and then call
    23  // OverrideBeaconConfig(c). Any subsequent calls to params.BeaconConfig() will
    24  // return this new configuration.
    25  func OverrideBeaconConfig(c *BeaconChainConfig) {
    26  	beaconConfigLock.Lock()
    27  	defer beaconConfigLock.Unlock()
    28  	beaconConfig = c
    29  }
    30  
    31  // Copy returns a copy of the config object.
    32  func (c *BeaconChainConfig) Copy() *BeaconChainConfig {
    33  	beaconConfigLock.RLock()
    34  	defer beaconConfigLock.RUnlock()
    35  	config, ok := deepcopy.Copy(*c).(BeaconChainConfig)
    36  	if !ok {
    37  		config = *beaconConfig
    38  	}
    39  	return &config
    40  }