diff --git a/analyzer/consensus/consensus.go b/analyzer/consensus/consensus.go index 4ba4249d7..6c8f7b8f3 100644 --- a/analyzer/consensus/consensus.go +++ b/analyzer/consensus/consensus.go @@ -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, diff --git a/analyzer/queries/queries.go b/analyzer/queries/queries.go index c5bc4e06d..7f25552e1 100644 --- a/analyzer/queries/queries.go +++ b/analyzer/queries/queries.go @@ -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)