-
Notifications
You must be signed in to change notification settings - Fork 42
/
proposal_server.go
41 lines (33 loc) · 1.15 KB
/
proposal_server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package keeper
import (
"context"
"github.com/omni-network/omni/halo/attest/types"
"github.com/omni-network/omni/lib/errors"
)
type proposalServer struct {
*Keeper
types.UnimplementedMsgServiceServer
}
// AddVotes verifies all aggregated votes included in a proposed block.
func (s proposalServer) AddVotes(ctx context.Context, msg *types.MsgAddVotes,
) (*types.AddVotesResponse, error) {
// Verify proposed msg
valset, err := s.prevBlockValSet(ctx)
if err != nil {
return nil, errors.Wrap(err, "fetch validators")
} else if err := s.verifyAggVotes(ctx, valset, msg.Votes); err != nil {
return nil, errors.Wrap(err, "verify votes")
}
localHeaders := headersByAddress(msg.Votes, s.voter.LocalAddress())
logLocalVotes(ctx, localHeaders, "proposed")
if err := s.voter.SetProposed(localHeaders); err != nil {
return nil, errors.Wrap(err, "set committed")
}
return &types.AddVotesResponse{}, nil
}
// NewProposalServer returns an implementation of the MsgServer interface
// for the provided Keeper.
func NewProposalServer(keeper *Keeper) types.MsgServiceServer {
return &proposalServer{Keeper: keeper}
}
var _ types.MsgServiceServer = proposalServer{}