Skip to content

Commit

Permalink
bridge inactive counter must always be initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed May 7, 2024
1 parent b6c2f13 commit 0d21ba2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions x/fbridge/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ func (k Keeper) InitMemStore(ctx sdk.Context) {
}
k.setRoleMetadata(noGasCtx, roleMetadata)

nInactive := k.GetBridgeInactiveCounter(noGasCtx)
nInactive := uint64(0)
for _, bs := range k.GetBridgeSwitches(ctx) {
if bs.Status == types.StatusInactive {
nInactive++
}
}
k.setBridgeInactiveCounter(noGasCtx, nInactive)

memStore := noGasCtx.KVStore(k.memKey)
Expand Down Expand Up @@ -143,13 +148,7 @@ func (k Keeper) GetBridgeInactiveCounter(ctx sdk.Context) uint64 {
memStore := ctx.KVStore(k.memKey)
bz := memStore.Get(types.KeyMemBridgeInactiveCounter)
if bz == nil {
n := uint64(0)
for _, bs := range k.GetBridgeSwitches(ctx) {
if bs.Status == types.StatusInactive {
n++
}
}
return n
panic("bridge inactive counter must be set at initialization")
}

return binary.BigEndian.Uint64(bz)
Expand Down

0 comments on commit 0d21ba2

Please sign in to comment.