postgres

package
v0.0.0-...-24865f3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 16 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 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 []byte) (address storage.Address, err error)

ByHash -

func (*Address) ListWithBalance

func (a *Address) ListWithBalance(ctx context.Context, fltrs storage.AddressListFilter) (result []storage.Address, 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 pkgTypes.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) (block storage.Block, err error)

ByHeight -

func (*Blocks) ByHeightWithStats

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

ByHeightWithStats -

func (*Blocks) ByIdWithRelations

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

ByIdWithRelations -

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

type DenomMetadata

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

DenomMetadata -

func NewDenomMetadata

func NewDenomMetadata(db *database.Bun) *DenomMetadata

NewDenomMetadata -

func (*DenomMetadata) All

func (dm *DenomMetadata) All(ctx context.Context) (metadata []storage.DenomMetadata, err error)

type Event

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

Event -

func NewEvent

func NewEvent(db *database.Bun) *Event

NewEvent -

func (*Event) ByBlock

func (e *Event) ByBlock(ctx context.Context, height pkgTypes.Level) (events []storage.Event, err error)

ByBlock -

func (*Event) ByTxId

func (e *Event) ByTxId(ctx context.Context, txId uint64) (events []storage.Event, err error)

ByTxId -

type Message

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

Message -

func NewMessage

func NewMessage(db *database.Bun) *Message

NewMessage -

func (*Message) ByTxId

func (m *Message) ByTxId(ctx context.Context, txId uint64) (messages []storage.Message, err error)

ByTxId -

type Namespace

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

Namespace -

func NewNamespace

func NewNamespace(db *database.Bun) *Namespace

NewNamespace -

func (*Namespace) Active

func (n *Namespace) Active(ctx context.Context, top int) (ns []storage.ActiveNamespace, err error)

func (*Namespace) ByNamespaceId

func (n *Namespace) ByNamespaceId(ctx context.Context, namespaceId []byte) (namespace []storage.Namespace, err error)

ByNamespaceId -

func (*Namespace) ByNamespaceIdAndVersion

func (n *Namespace) ByNamespaceIdAndVersion(ctx context.Context, namespaceId []byte, version byte) (namespace storage.Namespace, err error)

ByNamespaceIdAndVersion -

func (*Namespace) CountMessagesByHeight

func (n *Namespace) CountMessagesByHeight(ctx context.Context, height pkgTypes.Level) (int, error)

func (*Namespace) Messages

func (n *Namespace) Messages(ctx context.Context, id uint64, limit, offset int) (msgs []storage.NamespaceMessage, err error)

Messages -

func (*Namespace) MessagesByHeight

func (n *Namespace) MessagesByHeight(ctx context.Context, height pkgTypes.Level, limit, offset int) (msgs []storage.NamespaceMessage, err error)

MessagesByHeight -

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

func (s Stats) Count(ctx context.Context, req storage.CountRequest) (string, error)

func (Stats) Histogram

func (s Stats) Histogram(ctx context.Context, req storage.HistogramRequest) (response []storage.HistogramItem, err error)

func (Stats) HistogramCount

func (s Stats) HistogramCount(ctx context.Context, req storage.HistogramCountRequest) (response []storage.HistogramItem, err error)

func (Stats) Summary

func (s Stats) Summary(ctx context.Context, req storage.SummaryRequest) (string, error)

type Storage

type Storage struct {
	*postgres.Storage

	Blocks        models.IBlock
	BlockStats    models.IBlockStats
	Constants     models.IConstant
	DenomMetadata models.IDenomMetadata
	Tx            models.ITx
	Message       models.IMessage
	Event         models.IEvent
	Address       models.IAddress
	Namespace     models.INamespace
	State         models.IState
	Stats         models.IStats
	Validator     models.IValidator
	Notificator   *Notificator
	// contains filtered or unexported fields
}

Storage -

func Create

func Create(ctx context.Context, cfg config.Database) (Storage, error)

Create -

func (Storage) CreateListener

func (s Storage) CreateListener() models.Listener

type Transaction

type Transaction struct {
	storage.Transaction
}

func (Transaction) DeleteBalances

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

func (Transaction) LastAddressAction

func (tx Transaction) LastAddressAction(ctx context.Context, address []byte) (uint64, error)

func (Transaction) LastBlock

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

func (Transaction) Namespace

func (tx Transaction) Namespace(ctx context.Context, id uint64) (ns models.Namespace, err error)

func (Transaction) RollbackAddresses

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

func (Transaction) RollbackBlock

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

func (Transaction) RollbackBlockStats

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

func (Transaction) RollbackEvents

func (tx Transaction) RollbackEvents(ctx context.Context, height types.Level) (events []models.Event, err error)

func (Transaction) RollbackMessageAddresses

func (tx Transaction) RollbackMessageAddresses(ctx context.Context, msgIds []uint64) (err error)

func (Transaction) RollbackMessages

func (tx Transaction) RollbackMessages(ctx context.Context, height types.Level) (msgs []models.Message, err error)

func (Transaction) RollbackNamespaceMessages

func (tx Transaction) RollbackNamespaceMessages(ctx context.Context, height types.Level) (msgs []models.NamespaceMessage, err error)

func (Transaction) RollbackNamespaces

func (tx Transaction) RollbackNamespaces(ctx context.Context, height types.Level) (ns []models.Namespace, err error)

func (Transaction) RollbackSigners

func (tx Transaction) RollbackSigners(ctx context.Context, txIds []uint64) (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) SaveAddresses

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

func (Transaction) SaveBalances

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

func (Transaction) SaveConstants

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

func (Transaction) SaveEvents

func (tx Transaction) SaveEvents(ctx context.Context, events ...models.Event) error

func (Transaction) SaveMessages

func (tx Transaction) SaveMessages(ctx context.Context, msgs ...*models.Message) error

func (Transaction) SaveMsgAddresses

func (tx Transaction) SaveMsgAddresses(ctx context.Context, addresses ...models.MsgAddress) error

func (Transaction) SaveNamespaceMessage

func (tx Transaction) SaveNamespaceMessage(ctx context.Context, nsMsgs ...models.NamespaceMessage) error

func (Transaction) SaveNamespaces

func (tx Transaction) SaveNamespaces(ctx context.Context, namespaces ...*models.Namespace) (int64, error)

func (Transaction) SaveSigners

func (tx Transaction) SaveSigners(ctx context.Context, addresses ...models.Signer) 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)

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) ([]storage.Tx, error)

func (*Tx) ByHash

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

func (*Tx) ByIdWithRelations

func (tx *Tx) ByIdWithRelations(ctx context.Context, id uint64) (transaction storage.Tx, err error)

func (*Tx) Filter

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

func (*Tx) Genesis

func (tx *Tx) Genesis(ctx context.Context, limit, offset int, sortOrder sdk.SortOrder) (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) ByAddress

func (v *Validator) ByAddress(ctx context.Context, address string) (validator storage.Validator, err error)

Jump to

Keyboard shortcuts

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