mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
fix keys, return validation errors
This commit is contained in:
parent
e85d2f880b
commit
1a9b8514c9
@ -13,6 +13,7 @@ var (
|
|||||||
KeyGlobalDebtLimit = []byte("GlobalDebtLimit")
|
KeyGlobalDebtLimit = []byte("GlobalDebtLimit")
|
||||||
KeyCollateralParams = []byte("CollateralParams")
|
KeyCollateralParams = []byte("CollateralParams")
|
||||||
KeyDebtParams = []byte("DebtParams")
|
KeyDebtParams = []byte("DebtParams")
|
||||||
|
KeyCircuitBreaker = []byte("CircuitBreaker")
|
||||||
DefaultGlobalDebt = sdk.Coins{}
|
DefaultGlobalDebt = sdk.Coins{}
|
||||||
DefaultCircuitBreaker = false
|
DefaultCircuitBreaker = false
|
||||||
DefaultCollateralParams = CollateralParams{}
|
DefaultCollateralParams = CollateralParams{}
|
||||||
@ -117,9 +118,10 @@ func ParamKeyTable() params.KeyTable {
|
|||||||
// nolint
|
// nolint
|
||||||
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
||||||
return params.ParamSetPairs{
|
return params.ParamSetPairs{
|
||||||
{KeyGlobalDebtLimit, &p.GlobalDebtLimit},
|
{Key: KeyGlobalDebtLimit, Value: &p.GlobalDebtLimit},
|
||||||
{KeyCollateralParams, &p.CollateralParams},
|
{Key: KeyCollateralParams, Value: &p.CollateralParams},
|
||||||
{KeyDebtParams, &p.DebtParams},
|
{Key: KeyDebtParams, Value: &p.DebtParams},
|
||||||
|
{Key: KeyCircuitBreaker, Value: &p.CircuitBreaker},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +141,7 @@ func (p Params) Validate() error {
|
|||||||
debtParamsDebtLimit = debtParamsDebtLimit.Add(dp.DebtLimit)
|
debtParamsDebtLimit = debtParamsDebtLimit.Add(dp.DebtLimit)
|
||||||
}
|
}
|
||||||
if debtParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
if debtParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
||||||
fmt.Errorf("debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tdebt limits: %s",
|
return fmt.Errorf("debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tdebt limits: %s",
|
||||||
p.GlobalDebtLimit, debtParamsDebtLimit)
|
p.GlobalDebtLimit, debtParamsDebtLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ func (p Params) Validate() error {
|
|||||||
collateralParamsDebtLimit = collateralParamsDebtLimit.Add(cp.DebtLimit)
|
collateralParamsDebtLimit = collateralParamsDebtLimit.Add(cp.DebtLimit)
|
||||||
}
|
}
|
||||||
if collateralParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
if collateralParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
||||||
fmt.Errorf("collateral debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tcollateral debt limits: %s",
|
return fmt.Errorf("collateral debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tcollateral debt limits: %s",
|
||||||
p.GlobalDebtLimit, collateralParamsDebtLimit)
|
p.GlobalDebtLimit, collateralParamsDebtLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user