mirror of
https://github.com/lightninglabs/faraday.git
synced 2026-08-13 12:33:35 +02:00
Add a PruneChannelEvents query that bounds the channel_events table by both size and age in a single statement: an id-keyset offset enforces a maximum event count and a timestamp filter enforces a retention window, OR-joined so each limit applies independently. The query returns the number of rows deleted so callers can surface pruning activity. Add a standalone timestamp index so the global age-based prune does not scan the full table. The existing composite index leads with channel_id and cannot serve a channel-agnostic timestamp filter.
34 lines
1.6 KiB
Go
34 lines
1.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type Querier interface {
|
|
GetChannelByChanPoint(ctx context.Context, channelPoint string) (Channel, error)
|
|
GetChannelByShortChanID(ctx context.Context, shortChannelID int64) (Channel, error)
|
|
GetChannelEvents(ctx context.Context, arg GetChannelEventsParams) ([]ChannelEvent, error)
|
|
GetChannels(ctx context.Context) ([]GetChannelsRow, error)
|
|
GetLatestChannelEventBefore(ctx context.Context, arg GetLatestChannelEventBeforeParams) (ChannelEvent, error)
|
|
GetPeerByPubKey(ctx context.Context, pubkey string) (Peer, error)
|
|
InsertChannel(ctx context.Context, arg InsertChannelParams) (int64, error)
|
|
InsertChannelEvent(ctx context.Context, arg InsertChannelEventParams) error
|
|
InsertPeer(ctx context.Context, pubkey string) (int64, error)
|
|
// PruneChannelEventsByAge enforces the retention window on the channel_events
|
|
// table, returning the number of rows deleted. It deletes any row whose
|
|
// timestamp predates the given cutoff.
|
|
PruneChannelEventsByAge(ctx context.Context, timestamp time.Time) (int64, error)
|
|
// PruneChannelEventsBySize enforces the size ceiling on the channel_events
|
|
// table, returning the number of rows deleted. It keeps the newest rows by
|
|
// deleting everything with a smaller (earlier-inserted) id than the id found at
|
|
// the given offset from the newest row, so an offset of (max-events - 1) keeps
|
|
// exactly max-events rows.
|
|
PruneChannelEventsBySize(ctx context.Context, offset int32) (int64, error)
|
|
}
|
|
|
|
var _ Querier = (*Queries)(nil)
|