Skip to content

Commit

Permalink
fix: use correct gov version and fix metric overlapping (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored Jan 30, 2024
1 parent 1245caf commit 7dce6df
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/watcher/votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (w *VotesWatcher) Start(ctx context.Context) error {
node := w.pool.GetSyncedNode()
if node == nil {
log.Warn().Msg("no node available to fetch proposals")
} else if err := w.fetchProposalsV1(ctx, node); err != nil {
} else if err := w.fetchProposals(ctx, node); err != nil {
log.Error().Err(err).Msg("failed to fetch pending proposals")
}

Expand All @@ -55,13 +55,16 @@ func (w *VotesWatcher) Start(ctx context.Context) error {
}

func (w *VotesWatcher) fetchProposals(ctx context.Context, node *rpc.Node) error {
w.metrics.Vote.Reset()

switch w.options.GovModuleVersion {
case "v1beta1":
return w.fetchProposalsV1Beta1(ctx, node)
default: // v1
return w.fetchProposalsV1(ctx, node)
}
}

func (w *VotesWatcher) fetchProposalsV1(ctx context.Context, node *rpc.Node) error {
clientCtx := (client.Context{}).WithClient(node.Client)
queryClient := gov.NewQueryClient(clientCtx)
Expand Down Expand Up @@ -91,7 +94,6 @@ func (w *VotesWatcher) fetchProposalsV1(ctx context.Context, node *rpc.Node) err
Voter: voter,
})

w.metrics.Vote.Reset()
if isInvalidArgumentError(err) {
w.handleVoteV1(chainID, validator, proposal.Id, nil)
} else if err != nil {
Expand Down Expand Up @@ -149,7 +151,6 @@ func (w *VotesWatcher) fetchProposalsV1Beta1(ctx context.Context, node *rpc.Node
Voter: voter,
})

w.metrics.Vote.Reset()
if isInvalidArgumentError(err) {
w.handleVoteV1Beta1(chainID, validator, proposal.ProposalId, nil)
} else if err != nil {
Expand Down

0 comments on commit 7dce6df

Please sign in to comment.