mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-23 07:16:39 +00:00

* adjust issuePoPRewards to mint stagedCRDDL * add GetChallengeRange * add resolveStagedClaims on ReissueRDDLResult msg * move claim resolve to distribution result * add StagedDenom and ClaimDenom to config * added the prepare4linting.sh script * renamed PoPEpochs to PopEpochs * renamed DistributionAddressPoP to DistributionAddressPop * added config value ReIssuanceEpochs * detached the re-issuance from the distribution process and schedule them independently * changed logging messages * added an explicit util/kv_serialize.go file to have all KV serialization done * switched to Bigendian serialization of int64 to have the ordered list on the kvstore * added ComputeReIssuanceValue to enable re-issuances once a day or defined by ReIssuanceEpoch * integrated a ReIssuanceValue computation test case * adjusted the challenges test cases to be epoch-dependent * added ReIssuances per ReIssuanceEpoch * extended the Reissue message * checking ReIssuanceProposal in the ante handler * added precision setter for the UINT to RDDL token converter (and test cases) * add e2e test case for pop rewards Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package keeper
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/planetmint/planetmint-go/util"
|
|
"github.com/planetmint/planetmint-go/x/machine/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
func (k Keeper) StoreTrustAnchor(ctx sdk.Context, ta types.TrustAnchor, activated bool) error {
|
|
store := prefix.NewStore(ctx.KVStore(k.taStoreKey), types.KeyPrefix(types.TrustAnchorKey))
|
|
// if activated is set to true then store 1 else 0
|
|
var appendValue []byte
|
|
if activated {
|
|
appendValue = []byte{1}
|
|
} else {
|
|
appendValue = []byte{0}
|
|
}
|
|
pubKeyBytes, err := util.SerializeHexString(ta.Pubkey)
|
|
if err != nil {
|
|
return errors.New("the given public key could not be decoded (malformed string)")
|
|
}
|
|
store.Set(pubKeyBytes, appendValue)
|
|
return nil
|
|
}
|
|
|
|
func (k Keeper) GetTrustAnchor(ctx sdk.Context, pubKey string) (val types.TrustAnchor, activated bool, found bool) {
|
|
store := prefix.NewStore(ctx.KVStore(k.taStoreKey), types.KeyPrefix(types.TrustAnchorKey))
|
|
pubKeyBytes, err := util.SerializeHexString(pubKey)
|
|
if err != nil {
|
|
return val, false, false
|
|
}
|
|
trustAnchorActivated := store.Get(pubKeyBytes)
|
|
|
|
if trustAnchorActivated == nil {
|
|
return val, false, false
|
|
}
|
|
|
|
// if stored byte is 1 then return activated equals true
|
|
val.Pubkey = pubKey
|
|
if trustAnchorActivated[0] == 1 {
|
|
return val, true, true
|
|
}
|
|
return val, false, true
|
|
}
|