From 133c87ec27d08d7ded0d334e26ae812c7771fcef Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Sun, 9 May 2021 21:07:23 +0300 Subject: [PATCH] Don't fail when adding twice the same payment_hash --- db.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db.go b/db.go index 42dd66c..f26f92c 100644 --- a/db.go +++ b/db.go @@ -60,7 +60,8 @@ func registerPayment(destination, paymentHash, paymentSecret []byte, incomingAmo commandTag, err := pgxPool.Exec(context.Background(), `INSERT INTO payments (destination, payment_hash, payment_secret, incoming_amount_msat, outgoing_amount_msat) - VALUES ($1, $2, $3, $4, $5)`, + VALUES ($1, $2, $3, $4, $5) + ON CONFLICT DO NOTHING`, destination, paymentHash, paymentSecret, incomingAmountMsat, outgoingAmountMsat) log.Printf("registerPayment(%x, %x, %x, %v, %v) rows: %v err: %v", destination, paymentHash, paymentSecret, incomingAmountMsat, outgoingAmountMsat, commandTag.RowsAffected(), err)