Skip to content

Commit

Permalink
Merge pull request #517 from oasisprotocol/mitjat/upsert-votes
Browse files Browse the repository at this point in the history
bugfix: analyzer/consensus: votes: upsert instead of insert
  • Loading branch information
mitjat authored Sep 14, 2023
2 parents fb5d2fb + e2ee709 commit dd13ca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ func (m *processor) queueFinalizations(batch *storage.QueryBatch, data *storage.

func (m *processor) queueVotes(batch *storage.QueryBatch, data *storage.GovernanceData) error {
for _, vote := range data.Votes {
batch.Queue(queries.ConsensusVoteInsert,
batch.Queue(queries.ConsensusVoteUpsert,
vote.ID,
vote.Submitter.String(),
vote.Vote,
Expand Down
6 changes: 4 additions & 2 deletions analyzer/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,11 @@ var (
SET invalid_votes = $2
WHERE id = $1`

ConsensusVoteInsert = `
ConsensusVoteUpsert = `
INSERT INTO chain.votes (proposal, voter, vote)
VALUES ($1, $2, $3)`
VALUES ($1, $2, $3)
ON CONFLICT (proposal, voter) DO UPDATE SET
vote = excluded.vote;`

RuntimeBlockInsert = `
INSERT INTO chain.runtime_blocks (runtime, round, version, timestamp, block_hash, prev_block_hash, io_root, state_root, messages_hash, in_messages_hash, num_transactions, gas_used, size)
Expand Down

0 comments on commit dd13ca3

Please sign in to comment.