mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-30 10:46:37 +00:00

* added two new config variables: reissuance-asset and validator-address Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package dao
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
|
|
"github.com/planetmint/planetmint-go/config"
|
|
"github.com/planetmint/planetmint-go/util"
|
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
|
|
|
abci "github.com/cometbft/cometbft/abci/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
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 isPoPHeight(req.Header.GetHeight()) && util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
|
blockHeight := req.Header.GetHeight()
|
|
// TODO: implement PoP trigger
|
|
fmt.Println("TODO: implement PoP trigger")
|
|
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
|
conf := config.GetConfig()
|
|
tx_unsigned := GetReissuanceCommand(conf.ReissuanceAsset, blockHeight)
|
|
err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, tx_unsigned, blockHeight)
|
|
if err != nil {
|
|
logger.Error("error while initializing RDDL issuance", err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func isPoPHeight(height int64) bool {
|
|
cfg := config.GetConfig()
|
|
return height%int64(cfg.PoPEpochs) == 0
|
|
}
|
|
|
|
func EndBlocker(ctx sdk.Context, req abci.RequestEndBlock, k keeper.Keeper) {
|
|
k.DistributeCollectedFees(ctx)
|
|
}
|