mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
apply various pr suggestions
This commit is contained in:
parent
d1c0dd18b1
commit
ffbeced199
@ -57,30 +57,6 @@ func handleMsgVote(ctx sdk.Context, k keeper.Keeper, msg types.MsgVote) (*sdk.Re
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enact a proposal if it has enough votes
|
|
||||||
passes, err := k.GetProposalResult(ctx, msg.ProposalID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if passes {
|
|
||||||
err = k.EnactProposal(ctx, msg.ProposalID)
|
|
||||||
outcome := types.AttributeValueProposalPassed
|
|
||||||
if err != nil {
|
|
||||||
outcome = types.AttributeValueProposalFailed
|
|
||||||
}
|
|
||||||
k.DeleteProposalAndVotes(ctx, msg.ProposalID)
|
|
||||||
|
|
||||||
ctx.EventManager().EmitEvent(
|
|
||||||
sdk.NewEvent(
|
|
||||||
types.EventTypeProposalClose,
|
|
||||||
sdk.NewAttribute(types.AttributeKeyCommitteeID, fmt.Sprintf("%d", proposal.CommitteeID)),
|
|
||||||
sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.ID)),
|
|
||||||
sdk.NewAttribute(types.AttributeKeyProposalCloseStatus, outcome),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.EventManager().EmitEvent(
|
ctx.EventManager().EmitEvent(
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
sdk.EventTypeMessage,
|
sdk.EventTypeMessage,
|
||||||
@ -89,5 +65,31 @@ func handleMsgVote(ctx sdk.Context, k keeper.Keeper, msg types.MsgVote) (*sdk.Re
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Enact a proposal if it has enough votes
|
||||||
|
passes, err := k.GetProposalResult(ctx, msg.ProposalID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !passes {
|
||||||
|
return &sdk.Result{Events: ctx.EventManager().Events()}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = k.EnactProposal(ctx, msg.ProposalID)
|
||||||
|
outcome := types.AttributeValueProposalPassed
|
||||||
|
if err != nil {
|
||||||
|
outcome = types.AttributeValueProposalFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
k.DeleteProposalAndVotes(ctx, msg.ProposalID)
|
||||||
|
|
||||||
|
ctx.EventManager().EmitEvent(
|
||||||
|
sdk.NewEvent(
|
||||||
|
types.EventTypeProposalClose,
|
||||||
|
sdk.NewAttribute(types.AttributeKeyCommitteeID, fmt.Sprintf("%d", proposal.CommitteeID)),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.ID)),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyProposalCloseStatus, outcome),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
return &sdk.Result{Events: ctx.EventManager().Events()}, nil
|
return &sdk.Result{Events: ctx.EventManager().Events()}, nil
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxCommitteeDescriptionLength int = 5000
|
const MaxCommitteeDescriptionLength int = 512
|
||||||
|
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
// Committees
|
// Committees
|
||||||
|
Loading…
Reference in New Issue
Block a user