2020-09-21 21:08:43 +00:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/libs/kv"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
|
2020-12-21 17:18:55 +00:00
|
|
|
"github.com/kava-labs/kava/x/hard/types"
|
2020-09-21 21:08:43 +00:00
|
|
|
)
|
|
|
|
|
2020-12-21 17:18:55 +00:00
|
|
|
// DecodeStore unmarshals the KVPair's Value to the corresponding hard type
|
2020-09-21 21:08:43 +00:00
|
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string {
|
|
|
|
switch {
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.DepositsKeyPrefix):
|
|
|
|
var depA, depB types.Deposit
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &depA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &depB)
|
|
|
|
return fmt.Sprintf("%s\n%s", depA, depB)
|
2021-01-21 13:52:09 +00:00
|
|
|
case bytes.Equal(kvA.Key[:1], types.PreviousBlockTimeKey):
|
|
|
|
var timeA, timeB time.Time
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
|
|
|
return fmt.Sprintf("%s\n%s", timeA, timeB)
|
2020-09-21 21:08:43 +00:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("invalid %s key prefix %X", types.ModuleName, kvA.Key[:1]))
|
|
|
|
}
|
|
|
|
}
|