postgres

package
v0.0.0-...-67dfa23 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

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

Address -

func NewAddress

func NewAddress(db *database.Bun) *Address

NewAddress -

func (*Address) Filter

func (a *Address) Filter(ctx context.Context, fltr []storage.AddressFilter, opts ...storage.FilterOption) (result []storage.Address, err error)

Filter -

func (*Address) GetAddresses

func (a *Address) GetAddresses(ctx context.Context, ids ...uint64) (address []storage.Address, err error)

GetAddresses -

func (*Address) GetByHash

func (a *Address) GetByHash(ctx context.Context, hash []byte) (address storage.Address, err error)

GetByHash -

func (*Address) GetByHashes

func (a *Address) GetByHashes(ctx context.Context, hash [][]byte) (addresses []storage.Address, err error)

GetIdsByHash -

type Blocks

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

Blocks -

func NewBlocks

func NewBlocks(db *database.Bun) *Blocks

NewBlocks -

func (*Blocks) ByHeight

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

ByHeight -

func (*Blocks) ByStatus

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

ByStatus -

func (*Blocks) Last

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

Last -

type Class

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

Class -

func NewClass

func NewClass(db *database.Bun) *Class

NewClass -

func (*Class) GetByHash

func (c *Class) GetByHash(ctx context.Context, hash []byte) (class storage.Class, err error)

GetByHash -

func (*Class) GetUnresolved

func (c *Class) GetUnresolved(ctx context.Context) (classes []storage.Class, err error)

GetUnresolved -

type ClassReplace

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

ClassReplace -

func NewClassReplace

func NewClassReplace(db *database.Bun) *ClassReplace

NewClassReplace -

func (*ClassReplace) ByHeight

func (cr *ClassReplace) ByHeight(ctx context.Context, height uint64) (replaces []storage.ClassReplace, err error)

type Declare

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

Declare -

func NewDeclare

func NewDeclare(db *database.Bun) *Declare

NewDeclare -

func (*Declare) Filter

func (d *Declare) Filter(ctx context.Context, fltr []storage.DeclareFilter, opts ...storage.FilterOption) (result []storage.Declare, err error)

Filter -

func (*Declare) HashByHeight

func (d *Declare) HashByHeight(ctx context.Context, height uint64) (hash []byte, err error)

type Deploy

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

Deploy -

func NewDeploy

func NewDeploy(db *database.Bun) *Deploy

NewDeploy -

func (*Deploy) Filter

func (d *Deploy) Filter(ctx context.Context, fltr []storage.DeployFilter, opts ...storage.FilterOption) (result []storage.Deploy, err error)

Filter -

func (*Deploy) HashByHeight

func (d *Deploy) HashByHeight(ctx context.Context, height uint64) (hash []byte, err error)

type DeployAccount

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

DeployAccount -

func NewDeployAccount

func NewDeployAccount(db *database.Bun) *DeployAccount

NewDeployAccount -

func (*DeployAccount) Filter

func (d *DeployAccount) Filter(ctx context.Context, fltr []storage.DeployAccountFilter, opts ...storage.FilterOption) (result []storage.DeployAccount, err error)

Filter -

func (*DeployAccount) HashByHeight

func (d *DeployAccount) HashByHeight(ctx context.Context, height uint64) (hash []byte, err error)

type Event

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

Event -

func NewEvent

func NewEvent(db *database.Bun) *Event

NewEvent -

func (*Event) Count

func (e *Event) Count(ctx context.Context, fltr []storage.EventFilter) (uint64, error)

func (*Event) Filter

func (event *Event) Filter(ctx context.Context, fltr []storage.EventFilter, opts ...storage.FilterOption) (result []storage.Event, err error)

Filter -

type Fee

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

Fee -

func NewFee

func NewFee(db *database.Bun) *Fee

NewFee -

func (*Fee) Filter

func (fee *Fee) Filter(ctx context.Context, fltr []storage.FeeFilter, opts ...storage.FilterOption) (result []storage.Fee, err error)

Filter -

type Internal

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

Internal -

func NewInternal

func NewInternal(db *database.Bun) *Internal

NewInternal -

func (*Internal) Filter

func (d *Internal) Filter(ctx context.Context, fltr []storage.InternalFilter, opts ...storage.FilterOption) (result []storage.Internal, err error)

Filter -

func (*Internal) GetDeployedContracts

func (i *Internal) GetDeployedContracts(ctx context.Context, deployerBytes types.Hex) ([]storage.DeployedContract, error)

type Invoke

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

Invoke -

func NewInvoke

func NewInvoke(db *database.Bun) *Invoke

NewInvoke -

func (*Invoke) Count

func (d *Invoke) Count(ctx context.Context, fltr []storage.InvokeFilter) (uint64, error)

func (*Invoke) Filter

func (invoke *Invoke) Filter(ctx context.Context, fltr []storage.InvokeFilter, opts ...storage.FilterOption) (result []storage.Invoke, err error)

Filter -

func (*Invoke) HashByHeight

func (invoke *Invoke) HashByHeight(ctx context.Context, height uint64) (hash []byte, err error)

type L1Handler

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

L1Handler -

func NewL1Handler

func NewL1Handler(db *database.Bun) *L1Handler

NewL1Handler -

func (*L1Handler) Filter

func (l1 *L1Handler) Filter(ctx context.Context, fltr []storage.L1HandlerFilter, opts ...storage.FilterOption) (result []storage.L1Handler, err error)

Filter -

func (*L1Handler) HashByHeight

func (l1 *L1Handler) HashByHeight(ctx context.Context, height uint64) (hash []byte, err error)

type Message

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

Message -

func NewMessage

func NewMessage(db *database.Bun) *Message

NewMessage -

func (*Message) Filter

func (msg *Message) Filter(ctx context.Context, fltr []storage.MessageFilter, opts ...storage.FilterOption) (result []storage.Message, err error)

Filter -

type Proxy

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

Proxy -

func NewProxy

func NewProxy(db *database.Bun) *Proxy

NewProxy -

func (*Proxy) GetByHash

func (p *Proxy) GetByHash(ctx context.Context, address, selector []byte) (proxy storage.Proxy, err error)

GetByHash -

type ProxyUpgrade

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

ProxyUpgrade -

func NewProxyUpgrade

func NewProxyUpgrade(db *database.Bun) *ProxyUpgrade

NewProxyUpgrade -

func (*ProxyUpgrade) LastBefore

func (pu *ProxyUpgrade) LastBefore(ctx context.Context, hash, selector []byte, height uint64) (upg storage.ProxyUpgrade, err error)

LastBefore -

func (*ProxyUpgrade) ListWithHeight

func (pu *ProxyUpgrade) ListWithHeight(ctx context.Context, height uint64, limit, offset int) (upgrades []storage.ProxyUpgrade, err error)

ListWithHeight -

type RollbackManager

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

RollbackManager -

func NewRollbackManager

func NewRollbackManager(
	transactable storage.Transactable,
	state models.IState,
	blocks models.IBlock,
	proxyUpgrades models.IProxyUpgrade,
	classReplaces models.IClassReplace,
	transfers models.ITransfer,
) RollbackManager

NewRollbackManager -

func (RollbackManager) Rollback

func (rm RollbackManager) Rollback(ctx context.Context, indexerName string, height uint64) error

Rollback - rollback database to height

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 Storage

type Storage struct {
	*postgres.Storage

	Blocks models.IBlock

	Invoke        models.IInvoke
	Declare       models.IDeclare
	Deploy        models.IDeploy
	DeployAccount models.IDeployAccount
	L1Handler     models.IL1Handler
	Internal      models.IInternal
	Message       models.IMessage
	Event         models.IEvent
	Address       models.IAddress
	Class         models.IClass
	ClassReplaces models.IClassReplace
	StorageDiff   models.IStorageDiff
	Proxy         models.IProxy
	ProxyUpgrade  models.IProxyUpgrade
	Transfer      models.ITransfer
	Fee           models.IFee
	Token         models.IToken
	TokenBalance  models.ITokenBalance
	State         models.IState

	PartitionManager database.RangePartitionManager
	RollbackManager  RollbackManager
}

Storage -

func Create

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

Create -

type StorageDiff

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

StorageDiff -

func NewStorageDiff

func NewStorageDiff(db *database.Bun) *StorageDiff

NewStorageDiff -

func (*StorageDiff) Filter

func (sd *StorageDiff) Filter(ctx context.Context, fltr []storage.StorageDiffFilter, opts ...storage.FilterOption) (result []storage.StorageDiff, err error)

Filter -

func (*StorageDiff) GetOnBlock

func (sd *StorageDiff) GetOnBlock(ctx context.Context, height, contractId uint64, key []byte) (diff storage.StorageDiff, err error)

GetOnBlock -

type Token

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

Token -

func NewToken

func NewToken(db *database.Bun) *Token

NewToken -

func (*Token) Filter

func (token *Token) Filter(ctx context.Context, fltr []storage.TokenFilter, opts ...storage.FilterOption) (result []storage.Token, err error)

Filter -

func (*Token) Find

func (token *Token) Find(ctx context.Context, contractId uint64, tokenId string) (t storage.Token, err error)

Find -

func (*Token) ListByType

func (tokens *Token) ListByType(ctx context.Context, typ storage.TokenType, limit uint64, offset uint64, order sdk.SortOrder) (result []storage.Token, err error)

ListByType -

type TokenBalance

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

TokenBalance -

func NewTokenBalance

func NewTokenBalance(db *database.Bun) *TokenBalance

NewTokenBalance -

func (*TokenBalance) Balances

func (tb *TokenBalance) Balances(ctx context.Context, contractId uint64, tokenId int64, limit, offset int) (balances []storage.TokenBalance, err error)

Balances -

func (*TokenBalance) Filter

func (tb *TokenBalance) Filter(ctx context.Context, fltr []storage.TokenBalanceFilter, opts ...storage.FilterOption) (result []storage.TokenBalance, err error)

Filter -

type Transaction

type Transaction struct {
	storage.Transaction
}

Transaction -

func BeginTransaction

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

BeginTransaction -

func (Transaction) DeleteProxy

func (t Transaction) DeleteProxy(ctx context.Context, proxy models.Proxy) error

DeleteProxy -

func (Transaction) SaveAddresses

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

SaveAddress -

func (Transaction) SaveClassReplaces

func (t Transaction) SaveClassReplaces(ctx context.Context, replaces ...*models.ClassReplace) error

SaveClassReplaces -

func (Transaction) SaveClasses

func (t Transaction) SaveClasses(ctx context.Context, classes ...*models.Class) error

SaveClasses -

func (Transaction) SaveProxy

func (t Transaction) SaveProxy(ctx context.Context, proxy models.Proxy) error

SaveProxy -

func (Transaction) SaveTokenBalanceUpdates

func (t Transaction) SaveTokenBalanceUpdates(ctx context.Context, updates ...*models.TokenBalance) error

SaveTokenBalanceUpdates -

func (Transaction) SaveTokens

func (t Transaction) SaveTokens(ctx context.Context, tokens ...*models.Token) error

SaveTokens -

func (Transaction) UpdateStatus

func (t Transaction) UpdateStatus(ctx context.Context, height uint64, status models.Status, model any) error

UpdateStatus -

type Transfer

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

Transfer -

func NewTransfer

func NewTransfer(db *database.Bun) *Transfer

NewTransfer -

func (*Transfer) Count

func (t *Transfer) Count(ctx context.Context, fltr []storage.TransferFilter) (uint64, error)

func (*Transfer) Filter

func (t *Transfer) Filter(ctx context.Context, fltr []storage.TransferFilter, opts ...storage.FilterOption) (result []storage.Transfer, err error)

Filter -

Jump to

Keyboard shortcuts

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