mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-06 22:26:43 +00:00
added SendRDDLReissuanceResult sending by the proposer after the consensus over the ReissuanceProposal
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
8f76199214
commit
f69c978911
40
util/issue_commands.go
Normal file
40
util/issue_commands.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitRDDLReissuanceProcess(ctx sdk.Context, proposerAddress string, blk_height int64) error {
|
||||||
|
tx_unsigned, err := GetUnsignedReissuanceTransaction()
|
||||||
|
//blk_height := 0 //get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store
|
||||||
|
|
||||||
|
// Construct the command
|
||||||
|
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-proposal", hexProposerAddress, tx_unsigned, strconv.FormatInt(blk_height, 10))
|
||||||
|
|
||||||
|
// Start the command in a non-blocking way
|
||||||
|
err = cmd.Start()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error starting command: %s\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Command started in background")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendRDDLReissuanceResult(ctx sdk.Context, proposerAddress string, txID string, blk_height uint64) error {
|
||||||
|
// Construct the command
|
||||||
|
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-result", hexProposerAddress, txID, strconv.FormatInt(blk_height, 10))
|
||||||
|
|
||||||
|
// Start the command in a non-blocking way
|
||||||
|
err := cmd.Start()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error starting command: %s\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Command started in background")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
@ -3,8 +3,6 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/planetmint/planetmint-go/config"
|
"github.com/planetmint/planetmint-go/config"
|
||||||
"github.com/planetmint/planetmint-go/util"
|
"github.com/planetmint/planetmint-go/util"
|
||||||
@ -19,34 +17,18 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
|
|||||||
proposerAddress := req.Header.GetProposerAddress()
|
proposerAddress := req.Header.GetProposerAddress()
|
||||||
|
|
||||||
// Check if node is block proposer
|
// Check if node is block proposer
|
||||||
|
|
||||||
if isPoPHeight(req.Header.GetHeight()) && util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
if isPoPHeight(req.Header.GetHeight()) && util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
||||||
// TODO: implement PoP trigger
|
// TODO: implement PoP trigger
|
||||||
fmt.Println("TODO: implement PoP trigger")
|
fmt.Println("TODO: implement PoP trigger")
|
||||||
err := initRDDLReissuanceProcess(ctx, proposerAddress, req.Header.GetHeight())
|
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
||||||
|
err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, req.Header.GetHeight())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error while issuing RDDL", err)
|
logger.Error("error while issuing RDDL", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initRDDLReissuanceProcess(ctx sdk.Context, proposerAddress []byte, blk_height int64) error {
|
|
||||||
tx_unsigned, err := util.GetUnsignedReissuanceTransaction()
|
|
||||||
//blk_height := 0 //get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store
|
|
||||||
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
|
||||||
|
|
||||||
// Construct the command
|
|
||||||
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-proposal", hexProposerAddress, tx_unsigned, strconv.FormatInt(blk_height, 10))
|
|
||||||
|
|
||||||
// Start the command in a non-blocking way
|
|
||||||
err = cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error starting command: %s\n", err)
|
|
||||||
} else {
|
|
||||||
fmt.Println("Command started in background")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func isPoPHeight(height int64) bool {
|
func isPoPHeight(height int64) bool {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
return height%int64(cfg.PoPEpochs) == 0
|
return height%int64(cfg.PoPEpochs) == 0
|
||||||
|
@ -15,7 +15,10 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis
|
|||||||
if valid_result && msg.Proposer == validator_identity {
|
if valid_result && msg.Proposer == validator_identity {
|
||||||
// 1. sign tx
|
// 1. sign tx
|
||||||
// 2. broadcast tx
|
// 2. broadcast tx
|
||||||
|
|
||||||
|
txID := "asdlkufzaoisdfpoajf"
|
||||||
// 3. notarize result by notarizing the liquid tx-id
|
// 3. notarize result by notarizing the liquid tx-id
|
||||||
|
util.SendRDDLReissuanceResult(ctx, msg.GetProposer(), txID, msg.GetBlockheight())
|
||||||
}
|
}
|
||||||
|
|
||||||
var reissuance types.Reissuance
|
var reissuance types.Reissuance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user