postgres

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 28 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 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) 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)

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 Fee

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

Fee -

func NewFee

func NewFee(db *database.Bun) *Fee

NewFee -

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) 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)

type Storage

type Storage struct {
	*postgres.Storage

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

Storage -

func Create

func Create(ctx context.Context, cfg config.Database, scriptsDir string) (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) 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) 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) (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) 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) 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) error

func (Transaction) SaveConstants

func (tx Transaction) SaveConstants(ctx context.Context, constants ...models.Constant) 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) 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) 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) UpdateValidators

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

func (Transaction) Validators

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

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