store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SETUP_SQL string = `` /* 3145-byte string literal not displayed */

Variables

This section is empty.

Functions

func NewSQLiteStore

func NewSQLiteStore(fileName string) (giga.Store, error)

NewSQLiteStore returns a giga.PaymentsStore implementor that uses sqlite

Types

type Mock

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

func NewMock

func NewMock() Mock

NewMock returns a giga.PaymentsStore implementor that stores orders in memory

func (Mock) Commit

func (m Mock) Commit(updates []any) error

func (Mock) CreateAccount

func (m Mock) CreateAccount(account giga.Account) error

func (Mock) GetAccount

func (m Mock) GetAccount(foreignID string) (giga.Account, error)

func (Mock) GetAccountByAddress

func (m Mock) GetAccountByAddress(id giga.Address) (giga.Account, error)

func (Mock) GetAllUnreservedUTXOs

func (m Mock) GetAllUnreservedUTXOs(account giga.Address) ([]giga.UTXO, error)

func (Mock) GetChainState

func (m Mock) GetChainState() (giga.ChainState, error)

func (Mock) GetInvoice

func (m Mock) GetInvoice(id giga.Address) (giga.Invoice, error)

func (Mock) IncAccountChainSeq

func (m Mock) IncAccountChainSeq(accountId string) error

func (Mock) ListInvoices

func (m Mock) ListInvoices(account giga.Address, cursor int, limit int) (items []giga.Invoice, next_cursor int, err error)

func (Mock) MarkInvoiceAsPaid

func (m Mock) MarkInvoiceAsPaid(id giga.Address) error

func (Mock) RevertTxnsAboveHeight

func (m Mock) RevertTxnsAboveHeight(maxValidHeight int64) error

func (Mock) RevertUTXOsAboveHeight

func (m Mock) RevertUTXOsAboveHeight(maxValidHeight int64) error

func (Mock) StoreInvoice

func (m Mock) StoreInvoice(invoice giga.Invoice) error

func (Mock) UpdateAccount

func (m Mock) UpdateAccount(account giga.Account) error

func (Mock) UpdateChainState

func (m Mock) UpdateChainState(state giga.ChainState) error

type Queryable

type Queryable interface {
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
}

The common read-only parts of sql.DB and sql.Tx interfaces, so we can pass either one to some helper functions (for methods that appear on both SQLiteStore and SQLiteStoreTransaction)

type SQLiteStore

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

func (SQLiteStore) Begin

func (s SQLiteStore) Begin() (giga.StoreTransaction, error)

func (SQLiteStore) CalculateBalance

func (s SQLiteStore) CalculateBalance(accountID giga.Address) (giga.AccountBalance, error)

func (SQLiteStore) Close

func (s SQLiteStore) Close()

Defer this until shutdown

func (SQLiteStore) GetAccount

func (s SQLiteStore) GetAccount(foreignID string) (giga.Account, error)

func (SQLiteStore) GetAllUnreservedUTXOs

func (s SQLiteStore) GetAllUnreservedUTXOs(account giga.Address) (result []giga.UTXO, err error)

func (SQLiteStore) GetChainState

func (s SQLiteStore) GetChainState() (giga.ChainState, error)

func (SQLiteStore) GetInvoice

func (s SQLiteStore) GetInvoice(addr giga.Address) (giga.Invoice, error)

func (SQLiteStore) GetPayment

func (s SQLiteStore) GetPayment(account giga.Address, id int64) (giga.Payment, error)

func (SQLiteStore) GetServiceCursor

func (s SQLiteStore) GetServiceCursor(name string) (cursor int64, err error)

func (SQLiteStore) ListInvoices

func (s SQLiteStore) ListInvoices(account giga.Address, cursor int, limit int) (items []giga.Invoice, next_cursor int, err error)

func (SQLiteStore) ListPayments

func (s SQLiteStore) ListPayments(account giga.Address, cursor int64, limit int) (items []giga.Payment, next_cursor int64, err error)

type SQLiteStoreTransaction

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

func (SQLiteStoreTransaction) CalculateBalance

func (t SQLiteStoreTransaction) CalculateBalance(accountID giga.Address) (giga.AccountBalance, error)

func (*SQLiteStoreTransaction) Commit

func (t *SQLiteStoreTransaction) Commit() error

func (SQLiteStoreTransaction) ConfirmPayments

func (t SQLiteStoreTransaction) ConfirmPayments(confirmations int, blockHeight int64) (affectedAccounts []string, err error)

func (SQLiteStoreTransaction) ConfirmUTXOs

func (t SQLiteStoreTransaction) ConfirmUTXOs(confirmations int, blockHeight int64) (affectedAccounts []string, err error)

func (SQLiteStoreTransaction) CreateAccount

func (t SQLiteStoreTransaction) CreateAccount(acc giga.Account) error

func (SQLiteStoreTransaction) CreatePayment

func (t SQLiteStoreTransaction) CreatePayment(accountAddr giga.Address, payTo []giga.PayTo, total giga.CoinAmount, fee giga.CoinAmount) (giga.Payment, error)

func (SQLiteStoreTransaction) CreateUTXO

func (t SQLiteStoreTransaction) CreateUTXO(utxo giga.UTXO) error

func (SQLiteStoreTransaction) FindAccountForAddress

func (t SQLiteStoreTransaction) FindAccountForAddress(address giga.Address) (giga.Address, uint32, bool, error)

func (SQLiteStoreTransaction) GetAccount

func (t SQLiteStoreTransaction) GetAccount(foreignID string) (giga.Account, error)

func (SQLiteStoreTransaction) GetAccountByID

func (t SQLiteStoreTransaction) GetAccountByID(ID giga.Address) (giga.Account, error)

func (SQLiteStoreTransaction) GetAllUnreservedUTXOs

func (t SQLiteStoreTransaction) GetAllUnreservedUTXOs(account giga.Address) (result []giga.UTXO, err error)

func (SQLiteStoreTransaction) GetChainState

func (t SQLiteStoreTransaction) GetChainState() (giga.ChainState, error)

func (SQLiteStoreTransaction) GetInvoice

func (t SQLiteStoreTransaction) GetInvoice(addr giga.Address) (giga.Invoice, error)

func (SQLiteStoreTransaction) GetPayment

func (t SQLiteStoreTransaction) GetPayment(account giga.Address, id int64) (giga.Payment, error)

func (SQLiteStoreTransaction) IncChainSeqForAccounts

func (t SQLiteStoreTransaction) IncChainSeqForAccounts(accounts map[string]int64) error

func (SQLiteStoreTransaction) ListAccountsModifiedSince

func (t SQLiteStoreTransaction) ListAccountsModifiedSince(cursor int64, limit int) (ids []string, nextCursor int64, err error)

func (SQLiteStoreTransaction) ListInvoices

func (t SQLiteStoreTransaction) ListInvoices(account giga.Address, cursor int, limit int) (items []giga.Invoice, next_cursor int, err error)

func (SQLiteStoreTransaction) ListPayments

func (t SQLiteStoreTransaction) ListPayments(account giga.Address, cursor int64, limit int) (items []giga.Payment, next_cursor int64, err error)

func (SQLiteStoreTransaction) MarkInvoiceEventSent

func (t SQLiteStoreTransaction) MarkInvoiceEventSent(invoiceID giga.Address, event giga.EVENT_INV) error

func (SQLiteStoreTransaction) MarkInvoicesPaid

func (t SQLiteStoreTransaction) MarkInvoicesPaid(blockHeight int64, blockID string) (accounts []string, err error)

Mark all invoices paid that have corresponding confirmed UTXOs [via ConfirmUTXOs] that sum up to the invoice total, storing the given block-height. Returns the IDs of the Accounts that own any affected invoices (can return duplicates)

func (SQLiteStoreTransaction) MarkPaymentsOnChain

func (t SQLiteStoreTransaction) MarkPaymentsOnChain(txIDs []string, blockHeight int64) (accounts []string, err error)

Mark payments paid that match any of the txIDs (storing the given block-height) Returns the IDs of the Accounts that own any affected payments (can have duplicates)

func (SQLiteStoreTransaction) MarkUTXOSpent

func (t SQLiteStoreTransaction) MarkUTXOSpent(txID string, vOut int, blockHeight int64, spendTxID string) (id string, scriptAddress giga.Address, err error)

func (SQLiteStoreTransaction) RevertChangesAboveHeight

func (t SQLiteStoreTransaction) RevertChangesAboveHeight(maxValidHeight int64, seq int64) (int64, error)

func (SQLiteStoreTransaction) Rollback

func (t SQLiteStoreTransaction) Rollback() error

func (SQLiteStoreTransaction) SetServiceCursor

func (t SQLiteStoreTransaction) SetServiceCursor(name string, cursor int64) error

func (SQLiteStoreTransaction) StoreAddresses

func (t SQLiteStoreTransaction) StoreAddresses(accountID giga.Address, addresses []giga.Address, firstAddress uint32, isInternal bool) error

func (SQLiteStoreTransaction) StoreInvoice

func (t SQLiteStoreTransaction) StoreInvoice(inv giga.Invoice) error

Store an invoice

func (SQLiteStoreTransaction) UpdateAccount

func (t SQLiteStoreTransaction) UpdateAccount(acc giga.Account) error

func (SQLiteStoreTransaction) UpdateAccountBalance

func (t SQLiteStoreTransaction) UpdateAccountBalance(accountID giga.Address, bal giga.AccountBalance) error

func (SQLiteStoreTransaction) UpdateChainState

func (t SQLiteStoreTransaction) UpdateChainState(state giga.ChainState, writeRoot bool) error

func (SQLiteStoreTransaction) UpdatePaymentWithTxID

func (t SQLiteStoreTransaction) UpdatePaymentWithTxID(paymentID int64, txID string) error

type Scannable

type Scannable interface {
	Scan(dest ...any) error
}

Jump to

Keyboard shortcuts

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