mirror of
https://github.com/lightninglabs/faraday.git
synced 2026-08-17 13:07:41 +02:00
150 lines
3.8 KiB
Go
150 lines
3.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: chanevents.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const getChannelByChanPoint = `-- name: GetChannelByChanPoint :one
|
|
SELECT id, channel_point, short_channel_id, peer_id FROM channels WHERE channel_point = $1
|
|
`
|
|
|
|
func (q *Queries) GetChannelByChanPoint(ctx context.Context, channelPoint string) (Channel, error) {
|
|
row := q.db.QueryRowContext(ctx, getChannelByChanPoint, channelPoint)
|
|
var i Channel
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ChannelPoint,
|
|
&i.ShortChannelID,
|
|
&i.PeerID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getChannelByShortChanID = `-- name: GetChannelByShortChanID :one
|
|
SELECT id, channel_point, short_channel_id, peer_id FROM channels WHERE short_channel_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetChannelByShortChanID(ctx context.Context, shortChannelID int64) (Channel, error) {
|
|
row := q.db.QueryRowContext(ctx, getChannelByShortChanID, shortChannelID)
|
|
var i Channel
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ChannelPoint,
|
|
&i.ShortChannelID,
|
|
&i.PeerID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getChannelEvents = `-- name: GetChannelEvents :many
|
|
SELECT id, channel_id, event_type, timestamp, local_balance_sat, remote_balance_sat FROM channel_events
|
|
WHERE channel_id = $1 AND timestamp >= $2 AND timestamp < $3
|
|
ORDER BY timestamp ASC, id ASC
|
|
`
|
|
|
|
type GetChannelEventsParams struct {
|
|
ChannelID int64
|
|
Timestamp time.Time
|
|
Timestamp_2 time.Time
|
|
}
|
|
|
|
func (q *Queries) GetChannelEvents(ctx context.Context, arg GetChannelEventsParams) ([]ChannelEvent, error) {
|
|
rows, err := q.db.QueryContext(ctx, getChannelEvents, arg.ChannelID, arg.Timestamp, arg.Timestamp_2)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ChannelEvent
|
|
for rows.Next() {
|
|
var i ChannelEvent
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ChannelID,
|
|
&i.EventType,
|
|
&i.Timestamp,
|
|
&i.LocalBalanceSat,
|
|
&i.RemoteBalanceSat,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getPeerByPubKey = `-- name: GetPeerByPubKey :one
|
|
SELECT id, pubkey FROM peers WHERE pubkey = $1
|
|
`
|
|
|
|
func (q *Queries) GetPeerByPubKey(ctx context.Context, pubkey string) (Peer, error) {
|
|
row := q.db.QueryRowContext(ctx, getPeerByPubKey, pubkey)
|
|
var i Peer
|
|
err := row.Scan(&i.ID, &i.Pubkey)
|
|
return i, err
|
|
}
|
|
|
|
const insertChannel = `-- name: InsertChannel :one
|
|
INSERT INTO channels (channel_point, short_channel_id, peer_id) VALUES ($1, $2, $3) RETURNING id
|
|
`
|
|
|
|
type InsertChannelParams struct {
|
|
ChannelPoint string
|
|
ShortChannelID int64
|
|
PeerID int64
|
|
}
|
|
|
|
func (q *Queries) InsertChannel(ctx context.Context, arg InsertChannelParams) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, insertChannel, arg.ChannelPoint, arg.ShortChannelID, arg.PeerID)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const insertChannelEvent = `-- name: InsertChannelEvent :exec
|
|
INSERT INTO channel_events (
|
|
channel_id, event_type, timestamp, local_balance_sat, remote_balance_sat
|
|
) VALUES ($1, $2, $3, $4, $5)
|
|
`
|
|
|
|
type InsertChannelEventParams struct {
|
|
ChannelID int64
|
|
EventType int16
|
|
Timestamp time.Time
|
|
LocalBalanceSat sql.NullInt64
|
|
RemoteBalanceSat sql.NullInt64
|
|
}
|
|
|
|
func (q *Queries) InsertChannelEvent(ctx context.Context, arg InsertChannelEventParams) error {
|
|
_, err := q.db.ExecContext(ctx, insertChannelEvent,
|
|
arg.ChannelID,
|
|
arg.EventType,
|
|
arg.Timestamp,
|
|
arg.LocalBalanceSat,
|
|
arg.RemoteBalanceSat,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertPeer = `-- name: InsertPeer :one
|
|
INSERT INTO peers (pubkey) VALUES ($1) RETURNING id
|
|
`
|
|
|
|
func (q *Queries) InsertPeer(ctx context.Context, pubkey string) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, insertPeer, pubkey)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|