mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
params: add Defined
This commit is contained in:
parent
11ac2cc80f
commit
ee78ae4172
1 changed files with 9 additions and 0 deletions
|
|
@ -39,6 +39,15 @@ func (p Parameter[V]) Get(cfg *Config2) V {
|
|||
return p.info.defaultValue.(V)
|
||||
}
|
||||
|
||||
// Defined reports whether the parameter is set in the config.
|
||||
func (p Parameter[V]) Defined(cfg *Config2) bool {
|
||||
if p.info.id == 0 {
|
||||
panic("zero parameter")
|
||||
}
|
||||
_, ok := cfg.param[p.info.id]
|
||||
return ok
|
||||
}
|
||||
|
||||
// V creates a ParamValue with the given value. You need this to
|
||||
// specify parameter values when constructing a Config in code.
|
||||
func (p Parameter[V]) V(v V) ParamValue {
|
||||
|
|
|
|||
Loading…
Reference in a new issue