persistence

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHtlcAlreadySettled = errors.New("htlc already settled")

Functions

This section is empty.

Types

type Invoice

type Invoice struct {
	InvoiceCreationData

	SequenceNum       uint64
	SettleRequestedAt time.Time
	SettledAt         time.Time
	Settled           bool
}

type InvoiceCreationData

type InvoiceCreationData struct {
	types.InvoiceCreationData
}

type InvoiceState

type InvoiceState int
const (
	InvoiceStateAccepted InvoiceState = iota
	InvoiceStateSettleRequested
)

type PostgresPersister

type PostgresPersister struct {
	// contains filtered or unexported fields
}

PostgresPersister persists items to Postgres

func NewPostgresPersisterFromDSN

func NewPostgresPersisterFromDSN(dsn string, logger *zap.SugaredLogger) (
	*PostgresPersister, error)

NewPostgresPersisterFromDSN creates a new PostgresPersister using the dsn provided

func NewPostgresPersisterFromOptions

func NewPostgresPersisterFromOptions(options *pg.Options,
	logger *zap.SugaredLogger) *PostgresPersister

NewPostgresPersisterFromOptions creates a new PostgresPersister using the options provided

func (*PostgresPersister) Close

func (p *PostgresPersister) Close() error

func (*PostgresPersister) Get

func (*PostgresPersister) GetInvoices

func (p *PostgresPersister) GetInvoices(ctx context.Context,
	maxInvoicesCount, sequenceStart int) ([]*Invoice, error)

func (*PostgresPersister) MarkHtlcSettled

func (p *PostgresPersister) MarkHtlcSettled(ctx context.Context,
	key types.HtlcKey) (bool, error)

func (*PostgresPersister) Ping

func (p *PostgresPersister) Ping(ctx context.Context) error

Ping pings the database connection to ensure it is available

func (*PostgresPersister) RequestSettle

func (p *PostgresPersister) RequestSettle(ctx context.Context,
	invoice *InvoiceCreationData, htlcs map[types.HtlcKey]int64) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL