mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
fix: enforce sorting of cdp ids when storing (#475)
This commit is contained in:
parent
c175e9e856
commit
3cc2cc99b8
@ -2,6 +2,7 @@ package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -271,6 +272,7 @@ func (k Keeper) IndexCdpByOwner(ctx sdk.Context, cdp types.CDP) {
|
||||
return
|
||||
}
|
||||
cdpIDs = append(cdpIDs, cdp.ID)
|
||||
sort.Slice(cdpIDs, func(i, j int) bool { return cdpIDs[i] < cdpIDs[j] })
|
||||
store.Set(cdp.Owner, k.cdc.MustMarshalBinaryLengthPrefixed(cdpIDs))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user