mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-27 07:48:29 +00:00
refactor: IsValidatorBlockProposer no longer accepts proposerAddress because already given in ctx
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
0b17e93e9c
commit
f1e029eaf9
@ -8,6 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
|
||||
cometcfg "github.com/cometbft/cometbft/config"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
@ -48,12 +50,13 @@ func GetValidatorCometBFTIdentity(ctx sdk.Context, rootDir string) (validatorIde
|
||||
return
|
||||
}
|
||||
|
||||
func IsValidatorBlockProposer(ctx sdk.Context, proposerAddress []byte, rootDir string) (result bool) {
|
||||
func IsValidatorBlockProposer(ctx sdk.Context, rootDir string) (result bool) {
|
||||
validatorIdentity, err := GetValidatorCometBFTIdentity(ctx, rootDir)
|
||||
if err != nil {
|
||||
GetAppLogger().Error(ctx, errormsg.CouldNotGetValidatorIdentity+": "+err.Error())
|
||||
return
|
||||
}
|
||||
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
||||
hexProposerAddress := hex.EncodeToString(ctx.BlockHeader().ProposerAddress)
|
||||
result = hexProposerAddress == validatorIdentity
|
||||
return
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
|
||||
|
||||
// Check if node is block proposer
|
||||
// take the following actions only once, that's why we filter for the Block Proposer
|
||||
if !util.IsValidatorBlockProposer(ctx, proposerAddress, k.RootDir) {
|
||||
if !util.IsValidatorBlockProposer(ctx, k.RootDir) {
|
||||
return
|
||||
}
|
||||
currentBlockHeight := req.Header.GetHeight()
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
"github.com/planetmint/planetmint-go/util"
|
||||
"github.com/planetmint/planetmint-go/x/dao/types"
|
||||
)
|
||||
@ -27,12 +26,7 @@ func (k msgServer) InitPop(goCtx context.Context, msg *types.MsgInitPop) (*types
|
||||
amount := k.GetValidatorPoPReward(ctx)
|
||||
k.StoreChallangeInitiatorReward(ctx, msg.GetHeight(), amount)
|
||||
|
||||
validatorIdentity, err := util.GetValidatorCometBFTIdentity(ctx, k.RootDir)
|
||||
if err != nil {
|
||||
util.GetAppLogger().Error(ctx, initPopTag+errormsg.CouldNotGetValidatorIdentity+": "+err.Error())
|
||||
return nil, err
|
||||
}
|
||||
if msg.Initiator == validatorIdentity {
|
||||
if util.IsValidatorBlockProposer(ctx, k.RootDir) {
|
||||
go util.SendMqttPopInitMessagesToServer(ctx, challenge)
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ func (k msgServer) CreateRedeemClaim(goCtx context.Context, msg *types.MsgCreate
|
||||
redeemClaim,
|
||||
)
|
||||
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress, k.RootDir) {
|
||||
if util.IsValidatorBlockProposer(ctx, k.RootDir) {
|
||||
go postClaimToService(goCtx, msg.GetBeneficiary(), burnCoins.Amount.Uint64(), id)
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach
|
||||
return nil, types.ErrMachineTypeUndefined
|
||||
}
|
||||
params := k.GetParams(ctx)
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress, k.rootDir) {
|
||||
if util.IsValidatorBlockProposer(ctx, k.rootDir) {
|
||||
util.GetAppLogger().Info(ctx, "Issuing Machine NFT: "+msg.Machine.String())
|
||||
scheme := params.AssetRegistryScheme
|
||||
domain := params.AssetRegistryDomain
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user