Skip to content

Commit

Permalink
fix stake to maxcu list encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Aug 29, 2022
1 parent 7c6f414 commit 0313c13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions x/epochstorage/keeper/fixated_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (k Keeper) EncodeParam(param any) []byte {
k.buffer.Reset()
err := k.enc.Encode(param)
if err != nil {
panic("why god why")
panic("Can't Encode param: " + err.Error())
}
return k.buffer.Bytes()
}
Expand All @@ -87,7 +87,10 @@ func (k Keeper) EncodeParam(param any) []byte {
func (k Keeper) DecodeParam(rawData []byte, param any) {
k.buffer.Reset()
k.buffer.Write(rawData)
k.dec.Decode(param)
err := k.dec.Decode(param)
if err != nil {
panic("Can't Decode param: " + err.Error())
}
}

func (k Keeper) LatestFixatedParams(ctx sdk.Context, fixationKey string) (fixation types.FixatedParams, found bool) {
Expand Down
5 changes: 3 additions & 2 deletions x/pairing/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ func NewKeeper(

epochStorageKeeper.AddFixationRegistry(string(types.KeyServicersToPairCount), func(ctx sdk.Context) any { return keeper.ServicersToPairCountRaw(ctx) })
epochStorageKeeper.AddFixationRegistry(string(types.KeyStakeToMaxCUList), func(ctx sdk.Context) any {
culist, err := keeper.StakeToMaxCUListRaw(ctx).MarshalJSON()
culist := keeper.StakeToMaxCUListRaw(ctx)
data, err := culist.Marshal()
if err != nil { //out encoder cant encode this, we need marshal before sending
panic("failed to marshal stakeToCuList: ")
}
return culist
return data
})

return keeper
Expand Down

0 comments on commit 0313c13

Please sign in to comment.