pipelinedb

package
v0.0.0-...-b4d4280 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package pipelinedb handles the db persistence of transactions/pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(ctx context.Context, path string) (*DB, error)

func OpenDB

func OpenDB(ctx context.Context, path string, readOnly bool) (_ *DB, err error)

func OpenInMemoryDB

func OpenInMemoryDB(ctx context.Context) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) CountUnfinishedUnattachedPayoutGroup

func (db *DB) CountUnfinishedUnattachedPayoutGroup(ctx context.Context) (int64, error)

func (*DB) CreatePayoutGroup

func (db *DB) CreatePayoutGroup(ctx context.Context, payoutGroupID int64, payouts []*Payout) error

func (*DB) CreateTransaction

func (db *DB) CreateTransaction(ctx context.Context, tx Transaction) (*Transaction, error)

func (*DB) FetchFirstUnfinishedUnattachedPayoutGroup

func (db *DB) FetchFirstUnfinishedUnattachedPayoutGroup(ctx context.Context) (*PayoutGroup, error)

func (*DB) FetchPayoutGroup

func (db *DB) FetchPayoutGroup(ctx context.Context, id int64) (*PayoutGroup, error)

func (*DB) FetchPayoutGroupPayoutCount

func (db *DB) FetchPayoutGroupPayoutCount(ctx context.Context, payoutGroupID int64) (int64, error)

FetchPayoutGroupPayoutCount returns the count of payouts in a payout group.

func (*DB) FetchPayoutGroupPayouts

func (db *DB) FetchPayoutGroupPayouts(ctx context.Context, payoutGroupID int64) ([]*Payout, error)

FetchPayoutGroupPayouts returns all of the payouts for a given payout group.

func (*DB) FetchPayoutGroupTransactions

func (db *DB) FetchPayoutGroupTransactions(ctx context.Context, payoutGroupID int64) ([]*Transaction, error)

FetchPayoutGroupTransactions returns all of the transactions for a given payout group.

func (*DB) FetchPayoutProgress

func (db *DB) FetchPayoutProgress(ctx context.Context) (int64, int64, error)

func (*DB) FetchPayouts

func (db *DB) FetchPayouts(ctx context.Context) ([]*Payout, error)

func (*DB) FetchTransaction

func (db *DB) FetchTransaction(ctx context.Context, hash common.Hash) (*Transaction, error)

func (*DB) FetchTransactions

func (db *DB) FetchTransactions(ctx context.Context) ([]*Transaction, error)

func (*DB) FetchUnfinishedTransactionsSortedIntoNonceGroups

func (db *DB) FetchUnfinishedTransactionsSortedIntoNonceGroups(ctx context.Context) ([]*NonceGroup, error)

func (*DB) FinalizeNonceGroup

func (db *DB) FinalizeNonceGroup(ctx context.Context, nonceGroup *NonceGroup, statuses []*TxStatus) error

FinalizeNonceGroup finalizes the transaction state for transactions in a nonce group. It also sets the final tx hash on the payout group for the confirmed transaction.

func (*DB) RecordStart

func (db *DB) RecordStart(ctx context.Context, spender common.Address, owner *common.Address) error

func (*DB) Stats

func (db *DB) Stats(ctx context.Context) (_ *DBStats, err error)

func (*DB) UpdateTransactionState

func (db *DB) UpdateTransactionState(ctx context.Context, hash string, state TxState) error

type DBStats

type DBStats struct {
	Spender               *common.Address
	Owner                 *common.Address
	Payees                int64
	TotalPayouts          int64
	TotalUSD              decimal.Decimal
	PendingPayouts        int64
	PendingUSD            decimal.Decimal
	TotalPayoutGroups     int64
	PendingPayoutGroups   int64
	TotalTransactions     int64
	PendingTransactions   int64
	FailedTransactions    int64
	ConfirmedTransactions int64
	DroppedTransactions   int64
}

type NonceGroup

type NonceGroup struct {
	Nonce         uint64
	PayoutGroupID int64
	Txs           []Transaction
}

type Payout

type Payout struct {
	CSVLine       int
	Payee         common.Address
	USD           decimal.Decimal
	PayoutGroupID int64
}

func PayoutFromRow

func PayoutFromRow(row *payoutdb.Payout) (*Payout, error)

func PayoutsFromRows

func PayoutsFromRows(rows []*payoutdb.Payout) ([]*Payout, error)

type PayoutGroup

type PayoutGroup struct {
	ID          int64
	FinalTxHash *common.Hash
}

func PayoutGroupFromRow

func PayoutGroupFromRow(row *payoutdb.PayoutGroup) (*PayoutGroup, error)

func PayoutGroupsFromRows

func PayoutGroupsFromRows(rows []*payoutdb.PayoutGroup) ([]*PayoutGroup, error)

type Transaction

type Transaction struct {
	CreatedAt         time.Time
	Hash              string
	Owner             common.Address
	Spender           common.Address
	Nonce             uint64
	EstimatedGasPrice *big.Int
	StorjPrice        decimal.Decimal
	StorjTokens       *big.Int
	PayoutGroupID     int64
	Raw               []byte
	State             TxState
	Receipt           *types.Receipt
}

func TransactionFromRow

func TransactionFromRow(row *payoutdb.Transaction) (*Transaction, error)

func TransactionsFromRows

func TransactionsFromRows(rows []*payoutdb.Transaction) ([]*Transaction, error)

type TxState

type TxState string
const (
	// TxPending represents a transactions that has not been mined but is
	// still in the txpool.
	TxPending TxState = "pending"

	// TxDropped represents a transaction that has not been mined and is
	// no longer in the txpool. Safe to retry.
	TxDropped TxState = "dropped"

	// TxFailed represents a transaction that has been either mined and failed or failed during the submit.
	// Not safe to retry.
	TxFailed TxState = "failed"

	// TxConfirmed represents a transaction that has been mined and confirmed.
	TxConfirmed TxState = "confirmed"
)

func TxStateFromString

func TxStateFromString(s string) (TxState, bool)

type TxStatus

type TxStatus struct {
	Hash    string
	State   TxState
	Receipt *types.Receipt
}

Jump to

Keyboard shortcuts

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