mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-18 14:24:21 +01:00
remove existing insertchannel call
This commit is contained in:
@@ -226,22 +226,6 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes
|
||||
if chanResult != nil {
|
||||
log.Printf("paymentHash: %s, channel opened successfully alias: %v, confirmed: %v", reqPaymentHashStr, chanResult.InitialChannelID.ToString(), chanResult.ConfirmedChannelID.ToString())
|
||||
|
||||
err := i.store.InsertChannel(
|
||||
uint64(chanResult.InitialChannelID),
|
||||
uint64(chanResult.ConfirmedChannelID),
|
||||
channelPoint.String(),
|
||||
destination,
|
||||
time.Now(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("paymentHash: %s, insertChannel error: %v", reqPaymentHashStr, err)
|
||||
return common.InterceptResult{
|
||||
Action: common.INTERCEPT_FAIL_HTLC_WITH_CODE,
|
||||
FailureCode: common.FAILURE_TEMPORARY_CHANNEL_FAILURE,
|
||||
}, nil
|
||||
}
|
||||
|
||||
channelID := chanResult.ConfirmedChannelID
|
||||
if uint64(channelID) == 0 {
|
||||
channelID = chanResult.InitialChannelID
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package interceptor
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/breez/lspd/common"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
@@ -11,5 +9,4 @@ type InterceptStore interface {
|
||||
PaymentInfo(htlcPaymentHash []byte) (string, *common.OpeningFeeParams, []byte, []byte, []byte, int64, int64, *wire.OutPoint, *string, error)
|
||||
SetFundingTx(paymentHash []byte, channelPoint *wire.OutPoint) error
|
||||
RegisterPayment(token string, params *common.OpeningFeeParams, destination, paymentHash, paymentSecret []byte, incomingAmountMsat, outgoingAmountMsat int64, tag string) error
|
||||
InsertChannel(initialChanID, confirmedChanId uint64, channelPoint string, nodeID []byte, lastUpdate time.Time) error
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/breez/lspd/common"
|
||||
"github.com/breez/lspd/lightning"
|
||||
@@ -102,23 +101,3 @@ func (s *PostgresInterceptStore) RegisterPayment(token string, params *common.Op
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *PostgresInterceptStore) InsertChannel(initialChanID, confirmedChanId uint64, channelPoint string, nodeID []byte, lastUpdate time.Time) error {
|
||||
|
||||
query := `INSERT INTO
|
||||
channels (initial_chanid, confirmed_chanid, channel_point, nodeid, last_update)
|
||||
VALUES ($1, NULLIF($2, 0::int8), $3, $4, $5)
|
||||
ON CONFLICT (channel_point) DO UPDATE SET confirmed_chanid=NULLIF($2, 0::int8), last_update=$5`
|
||||
|
||||
c, err := s.pool.Exec(context.Background(),
|
||||
query, int64(initialChanID), int64(confirmedChanId), channelPoint, nodeID, lastUpdate)
|
||||
if err != nil {
|
||||
log.Printf("insertChannel(%v, %v, %s, %x) error: %v",
|
||||
initialChanID, confirmedChanId, channelPoint, nodeID, err)
|
||||
return fmt.Errorf("insertChannel(%v, %v, %s, %x) error: %w",
|
||||
initialChanID, confirmedChanId, channelPoint, nodeID, err)
|
||||
}
|
||||
log.Printf("insertChannel(%v, %v, %x) result: %v",
|
||||
initialChanID, confirmedChanId, nodeID, c.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user