fix panic(err) if posted_prices=[] in genesis file (#352)

This commit is contained in:
Denali Marsh 2020-01-29 16:12:47 -08:00 committed by GitHub
parent 55f0f8d980
commit 3c8209cbcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,9 +25,12 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, gs GenesisState) {
// Set the current price (if any) based on what's now in the store
for _, market := range params.Markets {
if market.Active {
err := keeper.SetCurrentPrices(ctx, market.MarketID)
if err != nil {
panic(err)
rps := keeper.GetRawPrices(ctx, market.MarketID)
if len(rps) > 0 {
err := keeper.SetCurrentPrices(ctx, market.MarketID)
if err != nil {
panic(err)
}
}
}
}