mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 09:14:28 +00:00
588dea83b7
* test coverage and updates to config twiddlers * LoadChainConfigFile error if SetActive conflicts * lint * wip working around test issues * more fixes, mass test updates * lint * linting * thanks deepsource! * fix undeclared vars * fixing more undefined * fix a bug, make a bug, repeat * gaz * use stock mainnet in case fork schedule matters * remove unused KnownConfigs * post-merge cleanup * eliminating OverrideBeaconConfig outside tests * more cleanup of OverrideBeaconConfig outside tests * config for interop w/ genesis gen support * improve var name * API on package instead of exported value * cleanup remainders of "registry" naming * Nishant feedback * add ropstein to configset * lint * lint #2 * ✂️ * revert accidental commented line * check if active is nil (replace called on empty) * Nishant feedback * replace OverrideBeaconConfig call * update interop instructions w/ new flag * don't let interop replace config set via cli flags Co-authored-by: kasey <kasey@users.noreply.github.com>
41 lines
979 B
Go
41 lines
979 B
Go
//go:build develop
|
|
// +build develop
|
|
|
|
package params
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/mohae/deepcopy"
|
|
)
|
|
|
|
var cfgrw sync.RWMutex
|
|
|
|
// BeaconConfig retrieves beacon chain config.
|
|
func BeaconConfig() *BeaconChainConfig {
|
|
cfgrw.RLock()
|
|
defer cfgrw.RUnlock()
|
|
return configs.getActive()
|
|
}
|
|
|
|
// 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) {
|
|
cfgrw.Lock()
|
|
defer cfgrw.Unlock()
|
|
configs.active = c
|
|
}
|
|
|
|
// Copy returns a copy of the config object.
|
|
func (b *BeaconChainConfig) Copy() *BeaconChainConfig {
|
|
cfgrw.RLock()
|
|
defer cfgrw.RUnlock()
|
|
config, ok := deepcopy.Copy(*b).(BeaconChainConfig)
|
|
if !ok {
|
|
panic("somehow deepcopy produced a BeaconChainConfig that is not of the same type as the original")
|
|
}
|
|
return &config
|
|
}
|