Skip to content

Commit 7283bbe

Browse files
authored
Merge pull request #45 from deso-protocol/fix-block-signers-insert
Fix block signers insert
2 parents b759a51 + 3dd7e16 commit 7283bbe

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

entries/utxo_operation.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,16 @@ func bulkInsertUtxoOperationsEntry(entries []*lib.StateChangeEntry, db *bun.DB,
301301
return errors.Wrapf(err, "entries.bulkInsertBlock: Error inserting entries")
302302
}
303303

304-
blockSignerQuery := db.NewInsert().Model(&pgBlockSigners)
304+
if len(pgBlockSigners) > 0 {
305+
blockSignerQuery := db.NewInsert().Model(&pgBlockSigners)
305306

306-
if operationType == lib.DbOperationTypeUpsert {
307-
blockSignerQuery = blockSignerQuery.On("CONFLICT (block_hash, signer_index) DO UPDATE")
308-
}
307+
if operationType == lib.DbOperationTypeUpsert {
308+
blockSignerQuery = blockSignerQuery.On("CONFLICT (block_hash, signer_index) DO UPDATE")
309+
}
309310

310-
if _, err := blockSignerQuery.Exec(context.Background()); err != nil {
311-
return errors.Wrapf(err, "entries.bulkInsertBlockSigners: Error inserting block signer entries")
311+
if _, err := blockSignerQuery.Exec(context.Background()); err != nil {
312+
return errors.Wrapf(err, "entries.bulkInsertBlockSigners: Error inserting block signer entries")
313+
}
312314
}
313315

314316
} else {

0 commit comments

Comments
 (0)