Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct gov version and fix metric overlapping #60

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: correct vote metric overlapping
MattKetmo committed Jan 30, 2024
commit 39a7c09dd251bfa3172a033f768e151d2ce97c12
7 changes: 4 additions & 3 deletions pkg/watcher/votes.go
Original file line number Diff line number Diff line change
@@ -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")
}

@@ -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)
@@ -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 {
@@ -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 {