Skip to content

Commit

Permalink
feat(bpos): modify to show sc min gas price payload in getcrproposals…
Browse files Browse the repository at this point in the history
…tate correctly
  • Loading branch information
RainFallsSilent committed Nov 1, 2023
1 parent 68c0713 commit 7324a96
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
49 changes: 30 additions & 19 deletions core/types/payload/crcproposal.go
Expand Up @@ -1483,25 +1483,26 @@ func (p *CRCProposal) Hash(payloadVersion byte) common.Uint256 {

func (p *CRCProposal) ToProposalInfo(payloadVersion byte) CRCProposalInfo {
info := CRCProposalInfo{
ProposalType: p.ProposalType,
CategoryData: p.CategoryData,
OwnerPublicKey: p.OwnerKey,
DraftHash: p.DraftHash,
Budgets: p.Budgets,
Recipient: p.Recipient,
TargetProposalHash: p.TargetProposalHash,
ReservedCustomIDList: p.ReservedCustomIDList,
ReceivedCustomIDList: p.ReceivedCustomIDList,
ReceiverDID: p.ReceiverDID,
RateOfCustomIDFee: p.RateOfCustomIDFee,
EIDEffectiveHeight: p.EIDEffectiveHeight,
NewRecipient: p.NewRecipient,
NewOwnerPublicKey: p.NewOwnerKey,
SecretaryGeneralPublicKey: p.SecretaryGeneralPublicKey,
SecretaryGeneralDID: p.SecretaryGeneralDID,
CRCouncilMemberDID: p.CRCouncilMemberDID,
SideChainInfo: p.SideChainInfo,
Hash: p.Hash(payloadVersion),
ProposalType: p.ProposalType,
CategoryData: p.CategoryData,
OwnerPublicKey: p.OwnerKey,
DraftHash: p.DraftHash,
Budgets: p.Budgets,
Recipient: p.Recipient,
TargetProposalHash: p.TargetProposalHash,
ReservedCustomIDList: p.ReservedCustomIDList,
ReceivedCustomIDList: p.ReceivedCustomIDList,
ReceiverDID: p.ReceiverDID,
RateOfCustomIDFee: p.RateOfCustomIDFee,
EIDEffectiveHeight: p.EIDEffectiveHeight,
NewRecipient: p.NewRecipient,
NewOwnerPublicKey: p.NewOwnerKey,
SecretaryGeneralPublicKey: p.SecretaryGeneralPublicKey,
SecretaryGeneralDID: p.SecretaryGeneralDID,
CRCouncilMemberDID: p.CRCouncilMemberDID,
SideChainInfo: p.SideChainInfo,
ChangeSideChainMinGasPriceInfo: p.ChangeSideChainMinGasPriceInfo,
Hash: p.Hash(payloadVersion),
}

if info.Budgets == nil {
Expand Down Expand Up @@ -1578,6 +1579,8 @@ type CRCProposalInfo struct {

SideChainInfo

ChangeSideChainMinGasPriceInfo

// The proposal hash
Hash common.Uint256
}
Expand Down Expand Up @@ -1675,6 +1678,10 @@ func (p *CRCProposalInfo) Serialize(w io.Writer, version byte) error {
return errors.New("failed to serialize SideChainInfo")
}

if err := p.ChangeSideChainMinGasPriceInfo.Serialize(w); err != nil {
return errors.New("failed to serialize ChangeSideChainMinGasPriceInfo")
}

if err := p.Hash.Serialize(w); err != nil {
return errors.New("failed to serialize Hash")
}
Expand Down Expand Up @@ -1786,6 +1793,10 @@ func (p *CRCProposalInfo) Deserialize(r io.Reader, version byte) error {
return errors.New("failed to deserialize SideChainInfo")
}

if err := p.ChangeSideChainMinGasPriceInfo.Deserialize(r); err != nil {
return errors.New("failed to deserialize ChangeSideChainMinGasPriceInfo")
}

if err := p.Hash.Deserialize(r); err != nil {
return errors.New("failed to deserialize Hash")
}
Expand Down
9 changes: 8 additions & 1 deletion servers/interfaces.go
Expand Up @@ -2959,11 +2959,18 @@ func GetCRProposalState(param Params) map[string]interface{} {
rpcProposal.SideChainInfo.MagicNumber = proposalState.Proposal.MagicNumber
rpcProposal.SideChainInfo.GenesisHash = common.ToReversedString(proposalState.Proposal.GenesisHash)
rpcProposal.SideChainInfo.ExchangeRate = proposalState.Proposal.ExchangeRate.String()
rpcProposal.SideChainInfo.EffectiveHeight = proposalState.Proposal.EffectiveHeight
rpcProposal.SideChainInfo.EffectiveHeight = proposalState.Proposal.SideChainInfo.EffectiveHeight
rpcProposal.SideChainInfo.ResourcePath = proposalState.Proposal.ResourcePath
did, _ := proposalState.Proposal.CRCouncilMemberDID.ToAddress()
rpcProposal.CRCouncilMemberDID = did
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
rpcProposalState.Proposal = rpcProposal
}

result := &RPCCRProposalStateInfo{ProposalState: rpcProposalState}
Expand Down

0 comments on commit 7324a96

Please sign in to comment.