Skip to content

Commit

Permalink
feat(bpos): modify to show ChangeSideChainMinGasPrice payload correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Nov 9, 2023
1 parent 328845e commit 0415a17
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
22 changes: 22 additions & 0 deletions servers/common.go
Expand Up @@ -400,11 +400,33 @@ type CRCRegisterSideChainProposalInfo struct {
}

type CRCChangeSideChainMinGasPriceInfo struct {
ProposalType string `json:"proposaltype"`
CategoryData string `json:"categorydata"`
OwnerPublicKey string `json:"ownerpublickey"`
DraftHash string `json:"drafthash"`
GenesisBlockHash string `json:"genesisblockhash"`
MinGasPrice string `json:"mingasprice"`
EffectiveHeight uint32 `json:"effectiveheight"`
Signature string `json:"signature"`
CRCouncilMemberDID string `json:"crcouncilmemberdid"`
CRCouncilMemberSignature string `json:"crcouncilmembersignature"`
}

type ChangeSideChainMinGasPriceInfo struct {
GenesisBlockHash string `json:"genesisblockhash"`
MinGasPrice string `json:"mingasprice"`
EffectiveHeight uint32 `json:"effectiveheight"`
}

type CRCChangeSideChainMinGasPriceProposal struct {
ProposalType string `json:"proposaltype"`
CategoryData string `json:"categorydata"`
OwnerPublicKey string `json:"ownerpublickey"`
DraftHash string `json:"drafthash"`
GasPriceInfo ChangeSideChainMinGasPriceInfo `json:"gaspriceinfo"`
CRCouncilMemberDID string `json:"crcouncilmemberdid"`
}

type CRCProposalReviewInfo struct {
ProposalHash string `json:"proposalhash"`
VoteResult string `json:"voteresult"`
Expand Down
25 changes: 21 additions & 4 deletions servers/interfaces.go
Expand Up @@ -2966,10 +2966,18 @@ func GetCRProposalState(param Params) map[string]interface{} {
rpcProposalState.Proposal = rpcProposal

case payload.ChangeSideChainMinGasPrice:
var rpcProposal CRCChangeSideChainMinGasPriceInfo
rpcProposal.GenesisBlockHash = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.GenesisBlockHash.String()
rpcProposal.MinGasPrice = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.MinGasPrice.String()
rpcProposal.EffectiveHeight = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.EffectiveHeight
var rpcProposal CRCChangeSideChainMinGasPriceProposal
rpcProposal.ProposalType = proposalState.Proposal.ProposalType.Name()
rpcProposal.CategoryData = proposalState.Proposal.CategoryData
rpcProposal.OwnerPublicKey = common.BytesToHexString(proposalState.Proposal.OwnerPublicKey)
rpcProposal.DraftHash = common.ToReversedString(proposalState.Proposal.DraftHash)

rpcProposal.GasPriceInfo.GenesisBlockHash = common.ToReversedString(proposalState.Proposal.ChangeSideChainMinGasPriceInfo.GenesisBlockHash)
rpcProposal.GasPriceInfo.MinGasPrice = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.MinGasPrice.String()
rpcProposal.GasPriceInfo.EffectiveHeight = proposalState.Proposal.ChangeSideChainMinGasPriceInfo.EffectiveHeight
did, _ := proposalState.Proposal.CRCouncilMemberDID.ToAddress()
rpcProposal.CRCouncilMemberDID = did

rpcProposalState.Proposal = rpcProposal
}

Expand Down Expand Up @@ -3494,9 +3502,18 @@ func getPayloadInfo(tx interfaces.Transaction, payloadVersion byte) PayloadInfo

case payload.ChangeSideChainMinGasPrice:
obj := new(CRCChangeSideChainMinGasPriceInfo)
obj.ProposalType = object.ProposalType.Name()
obj.CategoryData = object.CategoryData
obj.OwnerPublicKey = common.BytesToHexString(object.OwnerKey)
obj.DraftHash = common.ToReversedString(object.DraftHash)
obj.GenesisBlockHash = object.ChangeSideChainMinGasPriceInfo.GenesisBlockHash.String()
obj.MinGasPrice = object.ChangeSideChainMinGasPriceInfo.MinGasPrice.String()
obj.EffectiveHeight = object.ChangeSideChainMinGasPriceInfo.EffectiveHeight
obj.Signature = common.BytesToHexString(object.Signature)
crmdid, _ := object.CRCouncilMemberDID.ToAddress()
obj.CRCouncilMemberDID = crmdid
obj.CRCouncilMemberSignature = common.BytesToHexString(object.CRCouncilMemberSignature)

return obj
}

Expand Down

0 comments on commit 0415a17

Please sign in to comment.