postgres

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginTransaction

func BeginTransaction(ctx context.Context, tx storage.Transactable) (models.Transaction, error)

Types

type Action

type Action struct {
	*postgres.Table[*storage.Action]
}

Action -

func NewAction

func NewAction(db *database.Bun) *Action

NewAction -

func (*Action) ByAddress

func (a *Action) ByAddress(ctx context.Context, addressId uint64, filters storage.AddressActionsFilter) (actions []storage.AddressAction, err error)

func (*Action) ByBlock

func (a *Action) ByBlock(ctx context.Context, height types.Level, limit, offset int) (actions []storage.ActionWithTx, err error)

func (*Action) ByRollup

func (a *Action) ByRollup(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (actions []storage.RollupAction, err error)

func (*Action) ByRollupAndBridge

func (a *Action) ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs storage.RollupAndBridgeActionsFilter) (actions []storage.ActionWithTx, err error)

func (*Action) ByTxId

func (a *Action) ByTxId(ctx context.Context, txId uint64, limit, offset int) (actions []storage.Action, err error)

type Address

type Address struct {
	*postgres.Table[*storage.Address]
}

Address -

func NewAddress

func NewAddress(db *database.Bun) *Address

NewAddress -

func (*Address) ByHash

func (a *Address) ByHash(ctx context.Context, hash string) (address storage.Address, err error)

ByHash -

func (*Address) ListWithBalance

func (a *Address) ListWithBalance(ctx context.Context, fltrs storage.AddressListFilter) (address []storage.Address, err error)

type App added in v1.2.0

type App struct {
	*postgres.Table[*storage.App]
}

App -

func NewApp added in v1.2.0

func NewApp(db *database.Bun) *App

NewApp -

func (*App) BySlug added in v1.2.0

func (app *App) BySlug(ctx context.Context, slug string) (result storage.AppWithStats, err error)

func (*App) Leaderboard added in v1.2.0

func (app *App) Leaderboard(ctx context.Context, fltrs storage.LeaderboardFilters) (rollups []storage.AppWithStats, err error)

type BlockSignature

type BlockSignature struct {
	*postgres.Table[*storage.BlockSignature]
}

BlockSignature -

func NewBlockSignature

func NewBlockSignature(db *database.Bun) *BlockSignature

NewBlockSignature -

func (*BlockSignature) LevelsByValidator

func (bs *BlockSignature) LevelsByValidator(ctx context.Context, validatorId uint64, startHeight types.Level) (levels []types.Level, err error)

type BlockStats

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

BlockStats -

func NewBlockStats

func NewBlockStats(db *database.Bun) *BlockStats

NewBlockStats -

func (*BlockStats) ByHeight

func (b *BlockStats) ByHeight(ctx context.Context, height types.Level) (stats storage.BlockStats, err error)

ByHeight -

type Blocks

type Blocks struct {
	*postgres.Table[*storage.Block]
}

Blocks -

func NewBlocks

func NewBlocks(db *database.Bun) *Blocks

NewBlocks -

func (*Blocks) ByHash

func (b *Blocks) ByHash(ctx context.Context, hash []byte) (block storage.Block, err error)

ByHash -

func (*Blocks) ByHeight

func (b *Blocks) ByHeight(ctx context.Context, height types.Level, withStats bool) (block storage.Block, err error)

ByHeight -

func (*Blocks) ByIdWithRelations

func (b *Blocks) ByIdWithRelations(ctx context.Context, id uint64) (block storage.Block, err error)

func (*Blocks) ByProposer

func (b *Blocks) ByProposer(ctx context.Context, proposerId uint64, limit, offset int, order sdk.SortOrder) (blocks []storage.Block, err error)

func (*Blocks) Last

func (b *Blocks) Last(ctx context.Context) (block storage.Block, err error)

Last -

func (*Blocks) ListWithStats

func (b *Blocks) ListWithStats(ctx context.Context, limit, offset uint64, order sdk.SortOrder) (blocks []*storage.Block, err error)

ListWithStats -

type Bridge

type Bridge struct {
	*postgres.Table[*storage.Bridge]
}

Bridge -

func NewBridge

func NewBridge(db *database.Bun) *Bridge

NewBridge -

func (*Bridge) ByAddress

func (b *Bridge) ByAddress(ctx context.Context, addressId uint64) (bridge storage.Bridge, err error)

func (*Bridge) ById added in v1.1.0

func (b *Bridge) ById(ctx context.Context, id uint64) (bridge storage.Bridge, err error)

func (*Bridge) ByRoles

func (b *Bridge) ByRoles(ctx context.Context, addressId uint64, limit, offset int) (result []storage.Bridge, err error)

func (*Bridge) ByRollup

func (b *Bridge) ByRollup(ctx context.Context, rollupId uint64, limit, offset int) (bridge []storage.Bridge, err error)

func (*Bridge) ListWithAddress added in v1.1.0

func (b *Bridge) ListWithAddress(ctx context.Context, limit, offset int) (result []storage.Bridge, err error)

type Constant

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

Constant -

func NewConstant

func NewConstant(db *database.Bun) *Constant

NewConstant -

func (*Constant) All

func (constant *Constant) All(ctx context.Context) (c []storage.Constant, err error)

func (*Constant) ByModule

func (constant *Constant) ByModule(ctx context.Context, module types.ModuleName) (c []storage.Constant, err error)

func (*Constant) Get

func (constant *Constant) Get(ctx context.Context, module types.ModuleName, name string) (c storage.Constant, err error)

func (*Constant) IsNoRows

func (constant *Constant) IsNoRows(err error) bool

type Deposit added in v1.1.0

type Deposit struct {
	*postgres.Table[*storage.Deposit]
}

Fee -

func NewDeposit added in v1.1.0

func NewDeposit(db *database.Bun) *Deposit

NewDeposit -

func (*Deposit) ByBridgeId added in v1.1.0

func (d *Deposit) ByBridgeId(ctx context.Context, bridgeId uint64, limit, offset int, sort sdk.SortOrder) (deposits []storage.Deposit, err error)

func (*Deposit) ByRollupId added in v1.1.0

func (d *Deposit) ByRollupId(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (deposits []storage.Deposit, err error)

type Fee

type Fee struct {
	*postgres.Table[*storage.Fee]
}

Fee -

func NewFee

func NewFee(db *database.Bun) *Fee

NewFee -

func (*Fee) ByPayerId added in v1.1.0

func (f *Fee) ByPayerId(ctx context.Context, id uint64, limit, offset int, sort sdk.SortOrder) (fees []storage.Fee, err error)

func (*Fee) ByTxId added in v1.1.0

func (f *Fee) ByTxId(ctx context.Context, id uint64, limit, offset int) (fees []storage.Fee, err error)

type Notificator

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

func NewNotificator

func NewNotificator(cfg config.Database, db *bun.DB) *Notificator

func (*Notificator) Close

func (n *Notificator) Close() error

func (*Notificator) Listen

func (n *Notificator) Listen() chan *pq.Notification

func (*Notificator) Notify

func (n *Notificator) Notify(ctx context.Context, channel string, payload string) error

func (*Notificator) Subscribe

func (n *Notificator) Subscribe(ctx context.Context, channels ...string) error

type Rollup

type Rollup struct {
	*postgres.Table[*storage.Rollup]
}

Rollup -

func NewRollup

func NewRollup(db *database.Bun) *Rollup

NewRollup -

func (*Rollup) ActionsByHeight

func (r *Rollup) ActionsByHeight(ctx context.Context, height types.Level, limit, offset int) (actions []storage.RollupAction, err error)

func (*Rollup) ActionsByTxId

func (r *Rollup) ActionsByTxId(ctx context.Context, txId uint64, limit, offset int) (actions []storage.RollupAction, err error)

func (*Rollup) Addresses

func (r *Rollup) Addresses(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) (addresses []storage.RollupAddress, err error)

func (*Rollup) ByHash

func (r *Rollup) ByHash(ctx context.Context, hash []byte) (rollup storage.Rollup, err error)

func (*Rollup) CountActionsByHeight

func (r *Rollup) CountActionsByHeight(ctx context.Context, height types.Level) (int64, error)

func (*Rollup) CountActionsByTxId

func (r *Rollup) CountActionsByTxId(ctx context.Context, txId uint64) (int64, error)

func (*Rollup) ListExt

func (r *Rollup) ListExt(ctx context.Context, fltrs storage.RollupListFilter) (rollups []storage.Rollup, err error)

func (*Rollup) ListRollupsByAddress

func (r *Rollup) ListRollupsByAddress(ctx context.Context, addressId uint64, limit, offset int, sort sdk.SortOrder) (addresses []storage.RollupAddress, err error)
type Search struct {
	// contains filtered or unexported fields
}

Search -

func NewSearch

func NewSearch(db *database.Bun) *Search

NewSearch -

func (*Search) Search

func (s *Search) Search(ctx context.Context, query string) (results []storage.SearchResult, err error)

type SentryHook

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

func NewSentryHook

func NewSentryHook(dbName string, tracer trace.Tracer, formatQueries bool) *SentryHook

func (*SentryHook) AfterQuery

func (h *SentryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)

func (*SentryHook) BeforeQuery

func (h *SentryHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context

func (*SentryHook) Init

func (h *SentryHook) Init(db *bun.DB)

type State

type State struct {
	*postgres.Table[*storage.State]
}

State -

func NewState

func NewState(db *database.Bun) *State

NewState -

func (*State) ByName

func (s *State) ByName(ctx context.Context, name string) (state storage.State, err error)

ByName -

type Stats

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

func NewStats

func NewStats(conn *database.Bun) Stats

func (Stats) ActiveAddressesCount added in v1.1.0

func (s Stats) ActiveAddressesCount(ctx context.Context) (val int64, err error)

func (Stats) FeeSummary added in v1.1.0

func (s Stats) FeeSummary(ctx context.Context) (response []storage.FeeSummary, err error)

func (Stats) RollupSeries

func (s Stats) RollupSeries(ctx context.Context, rollupId uint64, timeframe storage.Timeframe, name string, req storage.SeriesRequest) (response []storage.SeriesItem, err error)

func (Stats) Series

func (s Stats) Series(ctx context.Context, timeframe storage.Timeframe, name string, req storage.SeriesRequest) (response []storage.SeriesItem, err error)

func (Stats) Summary

func (s Stats) Summary(ctx context.Context) (summary storage.NetworkSummary, err error)

func (Stats) SummaryTimeframe

func (s Stats) SummaryTimeframe(ctx context.Context, timeframe storage.Timeframe) (summary storage.NetworkSummaryWithChange, err error)

func (Stats) TokenTransferDistribution added in v1.1.0

func (s Stats) TokenTransferDistribution(ctx context.Context, limit int) (items []storage.TokenTransferDistributionItem, err error)

type Storage

type Storage struct {
	*postgres.Storage

	Blocks          models.IBlock
	BlockStats      models.IBlockStats
	Bridges         models.IBridge
	Constants       models.IConstant
	Tx              models.ITx
	Transfers       models.ITransfer
	Fee             models.IFee
	Deposit         models.IDeposit
	Action          models.IAction
	Address         models.IAddress
	Rollup          models.IRollup
	BlockSignatures models.IBlockSignature
	Validator       models.IValidator
	State           models.IState
	Search          models.ISearch
	Stats           models.IStats
	App             models.IApp
	Notificator     *Notificator
	// contains filtered or unexported fields
}

Storage -

func Create

func Create(ctx context.Context, cfg config.Database, scriptsDir string, withMigrations bool) (Storage, error)

Create -

func (Storage) CreateListener

func (s Storage) CreateListener() models.Listener

func (Storage) SetTracer

func (s Storage) SetTracer(tp trace.TracerProvider)

type Transaction

type Transaction struct {
	storage.Transaction
}

func (Transaction) DeleteApp added in v1.2.0

func (tx Transaction) DeleteApp(ctx context.Context, appId uint64) error

func (Transaction) GetAddressId added in v1.1.0

func (tx Transaction) GetAddressId(ctx context.Context, hash string) (addrId uint64, err error)

func (Transaction) GetBridgeIdByAddressId added in v1.1.0

func (tx Transaction) GetBridgeIdByAddressId(ctx context.Context, id uint64) (bridgeId uint64, err error)

func (Transaction) GetProposerId

func (tx Transaction) GetProposerId(ctx context.Context, address string) (id uint64, err error)

func (Transaction) GetRollup

func (tx Transaction) GetRollup(ctx context.Context, rollupId []byte) (rollup models.Rollup, err error)

func (Transaction) LastBlock

func (tx Transaction) LastBlock(ctx context.Context) (block models.Block, err error)

func (Transaction) LastNonce

func (tx Transaction) LastNonce(ctx context.Context, id uint64) (uint32, error)

func (Transaction) RefreshLeaderboard added in v1.2.0

func (tx Transaction) RefreshLeaderboard(ctx context.Context) error

func (Transaction) RetentionBlockSignatures

func (tx Transaction) RetentionBlockSignatures(ctx context.Context, height types.Level) error

func (Transaction) RollbackActions

func (tx Transaction) RollbackActions(ctx context.Context, height types.Level) (actions []models.Action, err error)

func (Transaction) RollbackAddressActions

func (tx Transaction) RollbackAddressActions(ctx context.Context, height types.Level) (addrActions []models.AddressAction, err error)

func (Transaction) RollbackAddresses

func (tx Transaction) RollbackAddresses(ctx context.Context, height types.Level) (address []models.Address, err error)

func (Transaction) RollbackBalanceUpdates

func (tx Transaction) RollbackBalanceUpdates(ctx context.Context, height types.Level) (updates []models.BalanceUpdate, err error)

func (Transaction) RollbackBalances

func (tx Transaction) RollbackBalances(ctx context.Context, ids []uint64) error

func (Transaction) RollbackBlock

func (tx Transaction) RollbackBlock(ctx context.Context, height types.Level) error

func (Transaction) RollbackBlockSignatures

func (tx Transaction) RollbackBlockSignatures(ctx context.Context, height types.Level) (err error)

func (Transaction) RollbackBlockStats

func (tx Transaction) RollbackBlockStats(ctx context.Context, height types.Level) (stats models.BlockStats, err error)

func (Transaction) RollbackBridges

func (tx Transaction) RollbackBridges(ctx context.Context, height types.Level) (int, error)

func (Transaction) RollbackDeposits added in v1.1.0

func (tx Transaction) RollbackDeposits(ctx context.Context, height types.Level) (err error)

func (Transaction) RollbackFees

func (tx Transaction) RollbackFees(ctx context.Context, height types.Level) (err error)

func (Transaction) RollbackRollupActions

func (tx Transaction) RollbackRollupActions(ctx context.Context, height types.Level) (rActions []models.RollupAction, err error)

func (Transaction) RollbackRollupAddresses

func (tx Transaction) RollbackRollupAddresses(ctx context.Context, height types.Level) (err error)

func (Transaction) RollbackRollups

func (tx Transaction) RollbackRollups(ctx context.Context, height types.Level) (rollups []models.Rollup, err error)

func (Transaction) RollbackTransfers added in v1.1.0

func (tx Transaction) RollbackTransfers(ctx context.Context, height types.Level) (err error)

func (Transaction) RollbackTxs

func (tx Transaction) RollbackTxs(ctx context.Context, height types.Level) (txs []models.Tx, err error)

func (Transaction) RollbackValidators

func (tx Transaction) RollbackValidators(ctx context.Context, height types.Level) (err error)

func (Transaction) SaveActions

func (tx Transaction) SaveActions(ctx context.Context, actions ...*models.Action) error

func (Transaction) SaveAddressActions

func (tx Transaction) SaveAddressActions(ctx context.Context, actions ...*models.AddressAction) error

func (Transaction) SaveAddresses

func (tx Transaction) SaveAddresses(ctx context.Context, addresses ...*models.Address) (int64, error)

func (Transaction) SaveApp added in v1.2.0

func (tx Transaction) SaveApp(ctx context.Context, app *models.App) error

func (Transaction) SaveBalanceUpdates

func (tx Transaction) SaveBalanceUpdates(ctx context.Context, updates ...models.BalanceUpdate) error

func (Transaction) SaveBalances

func (tx Transaction) SaveBalances(ctx context.Context, balances ...models.Balance) error

func (Transaction) SaveBlockSignatures

func (tx Transaction) SaveBlockSignatures(ctx context.Context, signs ...models.BlockSignature) error

func (Transaction) SaveBridges

func (tx Transaction) SaveBridges(ctx context.Context, bridges ...*models.Bridge) (int64, error)

func (Transaction) SaveConstants

func (tx Transaction) SaveConstants(ctx context.Context, constants ...models.Constant) error

func (Transaction) SaveDeposits added in v1.1.0

func (tx Transaction) SaveDeposits(ctx context.Context, deposits ...*models.Deposit) error

func (Transaction) SaveFees

func (tx Transaction) SaveFees(ctx context.Context, fees ...*models.Fee) error

func (Transaction) SaveRollupActions

func (tx Transaction) SaveRollupActions(ctx context.Context, actions ...*models.RollupAction) error

func (Transaction) SaveRollupAddresses

func (tx Transaction) SaveRollupAddresses(ctx context.Context, addresses ...*models.RollupAddress) error

func (Transaction) SaveRollups

func (tx Transaction) SaveRollups(ctx context.Context, rollups ...*models.Rollup) (int64, error)

func (Transaction) SaveTransactions

func (tx Transaction) SaveTransactions(ctx context.Context, txs ...*models.Tx) error

func (Transaction) SaveTransfers added in v1.1.0

func (tx Transaction) SaveTransfers(ctx context.Context, transfers ...*models.Transfer) error

func (Transaction) SaveValidators

func (tx Transaction) SaveValidators(ctx context.Context, validators ...*models.Validator) error

func (Transaction) State

func (tx Transaction) State(ctx context.Context, name string) (state models.State, err error)

func (Transaction) UpdateAddresses

func (tx Transaction) UpdateAddresses(ctx context.Context, addresses ...*models.Address) error

func (Transaction) UpdateApp added in v1.2.0

func (tx Transaction) UpdateApp(ctx context.Context, app *models.App) error

func (Transaction) UpdateConstants

func (tx Transaction) UpdateConstants(ctx context.Context, constants ...*models.Constant) error

func (Transaction) UpdateRollups

func (tx Transaction) UpdateRollups(ctx context.Context, rollups ...*models.Rollup) error

func (Transaction) Validators

func (tx Transaction) Validators(ctx context.Context) (validators []models.Validator, err error)

type Transfer added in v1.1.0

type Transfer struct {
	*postgres.Table[*storage.Transfer]
}

Transfer -

func NewTransfer added in v1.1.0

func NewTransfer(db *database.Bun) *Transfer

NewTransfer -

type Tx

type Tx struct {
	*postgres.Table[*storage.Tx]
}

Tx -

func NewTx

func NewTx(db *database.Bun) *Tx

NewTx -

func (*Tx) ByAddress

func (tx *Tx) ByAddress(ctx context.Context, addressId uint64, fltrs storage.TxFilter) (txs []storage.Tx, err error)

func (*Tx) ByHash

func (tx *Tx) ByHash(ctx context.Context, hash []byte) (transaction storage.Tx, err error)

func (*Tx) ByHeight

func (tx *Tx) ByHeight(ctx context.Context, height types.Level, limit, offset int) (txs []storage.Tx, err error)

func (*Tx) Filter

func (tx *Tx) Filter(ctx context.Context, fltrs storage.TxFilter) (txs []storage.Tx, err error)

type Validator

type Validator struct {
	*postgres.Table[*storage.Validator]
}

Validator -

func NewValidator

func NewValidator(db *database.Bun) *Validator

NewValidator -

func (*Validator) ListByPower

func (v *Validator) ListByPower(ctx context.Context, limit, offset int, order sdk.SortOrder) (validators []storage.Validator, err error)

Jump to

Keyboard shortcuts

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