mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
2 trigger token reissuance on liquid including the distribution (#96)
* add pop epochs to config * add config for triggering RDDL issuance --------- Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
8fd9f213f3
commit
c12a30c71a
@ -20,6 +20,9 @@ token-denom = "{{ .PlmntConfig.TokenDenom }}"
|
||||
stake-denom = "{{ .PlmntConfig.StakeDenom }}"
|
||||
fee-denom = "{{ .PlmntConfig.FeeDenom }}"
|
||||
config-root-dir = "{{ .PlmntConfig.ConfigRootDir }}"
|
||||
pop-epochs = {{ .PlmntConfig.PoPEpochs }}
|
||||
issuance-endpoint = "{{ .PlmntConfig.IssuanceEndpoint }}"
|
||||
issuance-port = {{ .PlmntConfig.IssuancePort }}
|
||||
`
|
||||
|
||||
// Config defines Planetmint's top level configuration
|
||||
@ -31,6 +34,9 @@ type Config struct {
|
||||
StakeDenom string `mapstructure:"stake-denom" json:"stake-denom"`
|
||||
FeeDenom string `mapstructure:"fee-denom" json:"fee-denom"`
|
||||
ConfigRootDir string `mapstructure:"config-root-dir" json:"config-root-dir"`
|
||||
PoPEpochs int `mapstructure:"pop-epochs" json:"pop-epochs"`
|
||||
IssuanceEndpoint string `mapstructure:"issuance-endpoint" json:"issuance-endpoint"`
|
||||
IssuancePort int `mapstructure:"issuance-port" json:"issuance-port"`
|
||||
}
|
||||
|
||||
// cosmos-sdk wide global singleton
|
||||
@ -54,6 +60,9 @@ func DefaultConfig() *Config {
|
||||
StakeDenom: "plmntstake",
|
||||
FeeDenom: "plmnt",
|
||||
ConfigRootDir: filepath.Join(currentUser.HomeDir, ".planetmint-go"),
|
||||
PoPEpochs: 24, // 24 CometBFT epochs of 5s equate 120s
|
||||
IssuanceEndpoint: "lab.r3c.network",
|
||||
IssuancePort: 7401,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/crgimenes/go-osc"
|
||||
"github.com/planetmint/planetmint-go/config"
|
||||
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
||||
|
||||
@ -29,15 +30,36 @@ type KeyFile struct {
|
||||
}
|
||||
|
||||
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
|
||||
logger := ctx.Logger()
|
||||
proposerAddress := req.Header.GetProposerAddress()
|
||||
|
||||
// Check if node is block proposer
|
||||
if isValidatorBlockProposer(ctx, proposerAddress) {
|
||||
if isPoPHeight(req.Header.GetHeight()) && isValidatorBlockProposer(ctx, proposerAddress) {
|
||||
// TODO: implement PoP trigger
|
||||
fmt.Println("TODO: implement PoP trigger")
|
||||
err := issueRDDL()
|
||||
if err != nil {
|
||||
logger.Error("error while issuing RDDL", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: define final message
|
||||
func issueRDDL() error {
|
||||
cfg := config.GetConfig()
|
||||
client := osc.NewClient(cfg.IssuanceEndpoint, cfg.IssuancePort)
|
||||
|
||||
msg := osc.NewMessage("/rddl/token")
|
||||
err := client.Send(msg)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func isPoPHeight(height int64) bool {
|
||||
cfg := config.GetConfig()
|
||||
return height%int64(cfg.PoPEpochs) == 0
|
||||
}
|
||||
|
||||
func isValidatorBlockProposer(ctx sdk.Context, proposerAddress []byte) bool {
|
||||
logger := ctx.Logger()
|
||||
conf := config.GetConfig()
|
||||
|
Loading…
x
Reference in New Issue
Block a user