mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
b54743edbf
* add mutex to params/config * split config files into test/prod * add tags checker * add regression test * remove debug info * update bazel config * go fmt * make sure that conditional file is kept by gazelle * update build tag: test -> develop * gazelle * remove redundant import * update deps.md (per Nishant's suggestion) Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
41 lines
986 B
Go
41 lines
986 B
Go
// +build develop
|
|
|
|
package params
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/mohae/deepcopy"
|
|
)
|
|
|
|
var beaconConfig = MainnetConfig()
|
|
var beaconConfigLock sync.RWMutex
|
|
|
|
// BeaconConfig retrieves beacon chain config.
|
|
func BeaconConfig() *BeaconChainConfig {
|
|
beaconConfigLock.RLock()
|
|
defer beaconConfigLock.RUnlock()
|
|
return beaconConfig
|
|
}
|
|
|
|
// OverrideBeaconConfig by replacing the config. The preferred pattern is to
|
|
// call BeaconConfig(), change the specific parameters, and then call
|
|
// OverrideBeaconConfig(c). Any subsequent calls to params.BeaconConfig() will
|
|
// return this new configuration.
|
|
func OverrideBeaconConfig(c *BeaconChainConfig) {
|
|
beaconConfigLock.Lock()
|
|
defer beaconConfigLock.Unlock()
|
|
beaconConfig = c
|
|
}
|
|
|
|
// Copy returns a copy of the config object.
|
|
func (c *BeaconChainConfig) Copy() *BeaconChainConfig {
|
|
beaconConfigLock.RLock()
|
|
defer beaconConfigLock.RUnlock()
|
|
config, ok := deepcopy.Copy(*c).(BeaconChainConfig)
|
|
if !ok {
|
|
config = *beaconConfig
|
|
}
|
|
return &config
|
|
}
|