storage

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelBlock    = "blocks"
	ChannelHead     = "head"
	ChannelTx       = "tx"
	ChannelConstant = "constant"
)
View Source
const (
	SeriesDataSize     = "data_size"
	SeriesTPS          = "tps"
	SeriesBPS          = "bps"
	SeriesRBPS         = "rbps"
	SeriesFee          = "fee"
	SeriesSupplyChange = "supply_change"
	SeriesBlockTime    = "block_time"
	SeriesTxCount      = "tx_count"
	SeriesBytesInBlock = "bytes_in_block"

	RollupSeriesActionsCount = "actions_count"
	RollupSeriesSize         = "size"
	RollupSeriesAvgSize      = "avg_size"
	RollupSeriesMinSize      = "min_size"
	RollupSeriesMaxSize      = "max_size"
)
View Source
const (
	ViewBlockStatsByHour     = "block_stats_by_hour"
	ViewBlockStatsByDay      = "block_stats_by_day"
	ViewBlockStatsByMonth    = "block_stats_by_month"
	ViewRollupStatsByHour    = "rollup_stats_by_hour"
	ViewRollupStatsByDay     = "rollup_stats_by_day"
	ViewRollupStatsByMonth   = "rollup_stats_by_month"
	ViewFeeStatsByHour       = "fee_stats_by_hour"
	ViewFeeStatsByDay        = "fee_stats_by_day"
	ViewFeeStatsByMonth      = "fee_stats_by_month"
	ViewTransferStatsByHour  = "transfer_stats_by_hour"
	ViewTransferStatsByDay   = "transfer_stats_by_day"
	ViewTransferStatsByMonth = "transfer_stats_by_month"
	ViewLeaderboard          = "leaderboard"
)

Variables

View Source
var (
	ErrValidation = errors.New("validation error")
)
View Source
var Models = []any{
	&State{},
	&Constant{},
	&Balance{},
	&BalanceUpdate{},
	&Address{},
	&Block{},
	&BlockStats{},
	&Tx{},
	&Action{},
	&Validator{},
	&Rollup{},
	&RollupAction{},
	&RollupAddress{},
	&AddressAction{},
	&BlockSignature{},
	&Bridge{},
	&Fee{},
	&Transfer{},
	&Deposit{},
	&App{},
}

Functions

This section is empty.

Types

type Action

type Action struct {
	bun.BaseModel `bun:"action" comment:"Table with actions"`

	Id       uint64           `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
	Height   pkgTypes.Level   `bun:",notnull"                    comment:"The number (height) of this block"`
	Time     time.Time        `bun:"time,pk,notnull"             comment:"The time of block"`
	Position int64            `bun:"position"                    comment:"Position in transaction"`
	Type     types.ActionType `bun:",type:action_type"           comment:"Action type"`
	TxId     uint64           `bun:"tx_id"                       comment:"Parent transaction id"`
	Data     map[string]any   `bun:"data,type:jsonb"             comment:"Action data"`

	// Rollup         *Rollup          `bun:"-"`
	Addresses      []*AddressAction `bun:"-"`
	BalanceUpdates []BalanceUpdate  `bun:"-"`
	RollupAction   *RollupAction    `bun:"-"`
	Fee            *Fee             `bun:"rel:has-one,join:id=action_id"`
	Deposit        *Deposit         `bun:"rel:has-one,join:id=action_id"`
}

Action -

func (Action) TableName

func (Action) TableName() string

TableName -

type ActionWithTx

type ActionWithTx struct {
	bun.BaseModel `bun:"action"`

	Action
	Tx *Tx `bun:"rel:belongs-to"`
}

type Address

type Address struct {
	bun.BaseModel `bun:"address" comment:"Table with addresses."`

	Id            uint64      `bun:"id,pk,notnull,autoincrement"  comment:"Unique internal identity"`
	Height        types.Level `bun:"height"                       comment:"Block number of the first address occurrence."`
	Hash          string      `bun:"hash,unique:address_hash"     comment:"Address hash"`
	Nonce         uint32      `bun:"nonce"                        comment:"Nonce"`
	ActionsCount  int64       `bun:"actions_count"                comment:"Count of actions in which the address was involved"`
	SignedTxCount int64       `bun:"signed_tx_count"              comment:"Count of signed transactions"`
	IsBridge      bool        `bun:"is_bridge"                    comment:"Indicate whether the account is a bridge or not"`
	IsIbcRelayer  *bool       `bun:"is_ibc_relayer,default:false" comment:"Indicate whether the account is a IBC realyer or not"`

	Balance []*Balance `bun:"rel:has-many,join:id=id"`
}

Address -

func (Address) String

func (address Address) String() string

func (Address) TableName

func (Address) TableName() string

TableName -

type AddressAction

type AddressAction struct {
	bun.BaseModel `bun:"address_action" comment:"Table with address actions"`

	AddressId  uint64           `bun:"address_id,pk"                comment:"Address internal id"`
	ActionId   uint64           `bun:"action_id,pk"                 comment:"Action internal id"`
	TxId       uint64           `bun:"tx_id"                        comment:"Tx internal id"`
	ActionType types.ActionType `bun:"action_type,type:action_type" comment:"Action type"`
	Time       time.Time        `bun:"time,notnull,pk"              comment:"Action time"`
	Height     pkgTypes.Level   `bun:"height"                       comment:"Action block height"`

	Address *Address `bun:"rel:belongs-to,join:address_id=id"`
	Action  *Action  `bun:"rel:belongs-to,join:action_id=id"`
	Tx      *Tx      `bun:"rel:belongs-to,join:tx_id=id"`
}

func (AddressAction) TableName

func (AddressAction) TableName() string

type AddressActionsFilter

type AddressActionsFilter struct {
	Limit       int
	Offset      int
	Sort        storage.SortOrder
	ActionTypes types.ActionTypeMask
}

type AddressListFilter

type AddressListFilter struct {
	Limit  int
	Offset int
	Sort   storage.SortOrder
	Asset  string
}

type App added in v1.2.0

type App struct {
	bun.BaseModel `bun:"app" comment:"Table with applications."`

	Id             uint64            `bun:"id,pk,notnull,autoincrement"            comment:"Unique internal identity"`
	Group          string            `bun:"group"                                  comment:"Application group"`
	Name           string            `bun:"name"                                   comment:"Application name"`
	Slug           string            `bun:"slug,unique:app_slug"                   comment:"Application slug"`
	Github         string            `bun:"github"                                 comment:"Application github link"`
	Twitter        string            `bun:"twitter"                                comment:"Application twitter account link"`
	Website        string            `bun:"website"                                comment:"Application website link"`
	Description    string            `bun:"description"                            comment:"Application description"`
	Explorer       string            `bun:"explorer"                               comment:"Application explorer link"`
	L2Beat         string            `bun:"l2beat"                                 comment:"Link to L2Beat"`
	Links          []string          `bun:"links,array"                            comment:"Additional links"`
	Stack          string            `bun:"stack"                                  comment:"Using stack"`
	VM             string            `bun:"vm"                                     comment:"Virtual machine"`
	Provider       string            `bun:"provider"                               comment:"RaaS"`
	Type           types.AppType     `bun:"type,type:app_type"                     comment:"Type of application: settled or sovereign"`
	Category       types.AppCategory `bun:"category,type:app_category"             comment:"Category of applications"`
	RollupId       uint64            `bun:"rollup_id,notnull,unique:app_rollup_id" comment:"Rollup internal identity"`
	NativeBridgeId uint64            `bun:"native_bridge_id"                       comment:"Native bridge internal id"`

	Bridge *Address `bun:"rel:belongs-to"`
	Rollup *Rollup  `bun:"rel:belongs-to"`
}

func (App) IsEmpty added in v1.2.0

func (app App) IsEmpty() bool

func (App) TableName added in v1.2.0

func (App) TableName() string

type AppStats added in v1.2.0

type AppStats struct {
	Size            int64     `bun:"size"`
	MinSize         int64     `bun:"min_size"`
	MaxSize         int64     `bun:"max_size"`
	AvgSize         float64   `bun:"avg_size"`
	ActionsCount    int64     `bun:"actions_count"`
	LastActionTime  time.Time `bun:"last_time"`
	FirstActionTime time.Time `bun:"first_time"`
}

type AppWithStats added in v1.2.0

type AppWithStats struct {
	App
	AppStats
}

type Balance

type Balance struct {
	bun.BaseModel `bun:"balance" comment:"Table with account balances"`

	Id       uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	Currency string          `bun:"currency,pk,notnull"         comment:"Balance currency"`
	Total    decimal.Decimal `bun:"total,type:numeric"          comment:"Total account balance"`
}

func EmptyBalance

func EmptyBalance() Balance

func (Balance) IsEmpty

func (b Balance) IsEmpty() bool

func (Balance) TableName

func (Balance) TableName() string

type BalanceUpdate

type BalanceUpdate struct {
	bun.BaseModel `bun:"balance_update" comment:"Table with account balance updates"`

	Id        uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	Height    pkgTypes.Level  `bun:",notnull"                    comment:"The number (height) of this block"`
	AddressId uint64          `bun:"address_id"                  comment:"Address internal identity"`
	Update    decimal.Decimal `bun:"update,type:numeric"         comment:"Balance update"`
	Currency  string          `bun:"currency"                    comment:"Currency"`

	Address *Address `bun:"rel:belongs-to"`
}

func (BalanceUpdate) TableName

func (BalanceUpdate) TableName() string

type Block

type Block struct {
	bun.BaseModel `bun:"table:block" comment:"Table with blocks"`

	Id           uint64         `bun:",pk,notnull,autoincrement" comment:"Unique internal identity"`
	Height       pkgTypes.Level `bun:"height"                    comment:"The number (height) of this block"`
	Time         time.Time      `bun:"time,pk,notnull"           comment:"The time of block"`
	VersionBlock uint64         `bun:"version_block"             comment:"Block version"`
	VersionApp   uint64         `bun:"version_app"               comment:"App version"`

	Hash               pkgTypes.Hex `bun:"hash"                 comment:"Block hash"`
	ParentHash         pkgTypes.Hex `bun:"parent_hash"          comment:"Hash of parent block"`
	LastCommitHash     pkgTypes.Hex `bun:"last_commit_hash"     comment:"Last commit hash"`
	DataHash           pkgTypes.Hex `bun:"data_hash"            comment:"Data hash"`
	ValidatorsHash     pkgTypes.Hex `bun:"validators_hash"      comment:"Validators hash"`
	NextValidatorsHash pkgTypes.Hex `bun:"next_validators_hash" comment:"Next validators hash"`
	ConsensusHash      pkgTypes.Hex `bun:"consensus_hash"       comment:"Consensus hash"`
	AppHash            pkgTypes.Hex `bun:"app_hash"             comment:"App hash"`
	LastResultsHash    pkgTypes.Hex `bun:"last_results_hash"    comment:"Last results hash"`
	EvidenceHash       pkgTypes.Hex `bun:"evidence_hash"        comment:"Evidence hash"`
	ProposerId         uint64       `bun:"proposer_id,nullzero" comment:"Proposer internal id"`
	ActionTypes        types.Bits   `bun:"action_types"         comment:"Bit mask for action types contained in block"`

	ChainId         string                    `bun:"-"` // internal field for filling state
	ProposerAddress string                    `bun:"-"` // internal field for proposer
	Addresses       map[string]*Address       `bun:"-"` // internal field for saving address
	Rollups         map[string]*Rollup        `bun:"-"` // internal field for saving rollups
	RollupAddress   map[string]*RollupAddress `bun:"-"` // internal field for saving rollup address
	Validators      map[string]*Validator     `bun:"-"` // internal field for updating validators
	BlockSignatures []BlockSignature          `bun:"-"` // internal field for saving block signatures
	Constants       []*Constant               `bun:"-"` // internal field for updating constants
	Bridges         []*Bridge                 `bun:"-"` // internal field for saving bridges
	Transfers       []*Transfer               `bun:"-"` // internal field for saving transfers

	Txs      []*Tx       `bun:"rel:has-many"`
	Stats    *BlockStats `bun:"rel:has-one,join:height=height"`
	Proposer *Validator  `bun:"rel:belongs-to"`
}

Block -

func (Block) TableName

func (Block) TableName() string

TableName -

type BlockSignature

type BlockSignature struct {
	bun.BaseModel `bun:"block_signature" comment:"Table with block signatures"`

	Id          uint64         `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
	Height      pkgTypes.Level `bun:",notnull"                    comment:"The number (height) of this block"`
	Time        time.Time      `bun:"time,pk,notnull"             comment:"The time of block"`
	ValidatorId uint64         `bun:"validator_id"                comment:"Validator's internal identity"`

	Validator *Validator `bun:"rel:belongs-to"`
}

func (BlockSignature) TableName

func (BlockSignature) TableName() string

type BlockStats

type BlockStats struct {
	bun.BaseModel `bun:"table:block_stats" comment:"Table with block stats"`

	Id     uint64         `bun:",pk,notnull,autoincrement" comment:"Unique internal identity"`
	Height pkgTypes.Level `bun:"height"                    comment:"The number (height) of this block"`
	Time   time.Time      `bun:"time,pk,notnull"           comment:"The time of block"`

	TxCount      int64           `bun:"tx_count"         comment:"Count of transactions in block"`
	BlockTime    uint64          `bun:"block_time"       comment:"Time in milliseconds between current and previous block"`
	SupplyChange decimal.Decimal `bun:",type:numeric"    comment:"Change of total supply in the block"`
	Fee          decimal.Decimal `bun:"fee,type:numeric" comment:"Summary block fee"`
	BytesInBlock int64           `bun:"bytes_in_block"   comment:"Size of all transactions in bytes"`
	DataSize     int64           `bun:"data_size"        comment:"Size of all rollup data in block"`
}

func (BlockStats) TableName

func (BlockStats) TableName() string

type Bridge

type Bridge struct {
	bun.BaseModel `bun:"table:bridge" comment:"Table with bridges"`

	Id           uint64         `bun:"id,pk,notnull,autoincrement"         comment:"Unique internal identity"`
	RollupId     uint64         `bun:"rollup_id"                           comment:"Rollup id"`
	AddressId    uint64         `bun:"address_id,unique:bridge_address_id" comment:"Address id"`
	Asset        string         `bun:"asset"                               comment:"Asset"`
	FeeAsset     string         `bun:"fee_asset"                           comment:"Fee asset"`
	SudoId       uint64         `bun:"sudo_id"                             comment:"Address which is authorized to change the bridge"`
	WithdrawerId uint64         `bun:"withdrawer_id"                       comment:"Address which is used to make withdrawals from the bridge account"`
	InitHeight   pkgTypes.Level `bun:"init_height"                         comment:"Height when bridge was initialized"`

	Rollup     *Rollup  `bun:"rel:has-one,join:rollup_id=id"`
	Address    *Address `bun:"rel:has-one,join:address_id=id"`
	Sudo       *Address `bun:"rel:has-one,join:sudo_id=id"`
	Withdrawer *Address `bun:"rel:has-one,join:withdrawer_id=id"`
}

func (Bridge) TableName

func (Bridge) TableName() string

type Constant

type Constant struct {
	bun.BaseModel `bun:"table:constant" comment:"Table with constants"`

	Module types.ModuleName `bun:"module,pk,type:module_name" comment:"Module name which declares constant" json:"module"`
	Name   string           `bun:"name,pk,type:text"          comment:"Constant name"                       json:"name"`
	Value  string           `bun:"value,type:text"            comment:"Constant value"                      json:"value"`
}

func (Constant) TableName

func (Constant) TableName() string

type Deposit added in v1.1.0

type Deposit struct {
	bun.BaseModel `bun:"deposit" comment:"Table with deposits"`

	Id                      uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
	Height                  pkgTypes.Level  `bun:",notnull"                    comment:"The number (height) of this block"`
	Time                    time.Time       `bun:"time,pk,notnull"             comment:"The time of block"`
	BridgeId                uint64          `bun:"bridge_id"                   comment:"Bridge id"`
	RollupId                uint64          `bun:"rollup_id"                   comment:"Rollup id"`
	Asset                   string          `bun:"asset"                       comment:"Deposit asset"`
	Amount                  decimal.Decimal `bun:"amount,type:numeric"         comment:"Deposit amount"`
	DestinationChainAddress string          `bun:"destination_chain_address"   comment:"Destination chain address"`
	ActionId                uint64          `bun:"action_id"                   comment:"Internal action id"`
	TxId                    uint64          `bun:"tx_id"                       comment:"Internal transaction id"`

	Bridge *Bridge `bun:"rel:belongs-to"`
	Rollup *Rollup `bun:"rel:belongs-to"`
	Action *Action `bun:"rel:belongs-to"`
	Tx     *Tx     `bun:"rel:belongs-to"`
}

func (*Deposit) TableName added in v1.1.0

func (*Deposit) TableName() string

type Fee

type Fee struct {
	bun.BaseModel `bun:"table:fee" comment:"Table with fees"`

	Id       uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	Height   pkgTypes.Level  `bun:"height,notnull"              comment:"The number (height) of this block"`
	Time     time.Time       `bun:"time,pk,notnull"             comment:"The time of block"`
	Asset    string          `bun:"asset"                       comment:"Fee asset"`
	Amount   decimal.Decimal `bun:"amount,type:numeric"         comment:"Fee amount"`
	ActionId uint64          `bun:"action_id"                   comment:"Connected action id"`
	TxId     uint64          `bun:"tx_id"                       comment:"Connected transaction id"`
	PayerId  uint64          `bun:"payer_id"                    comment:"Who paid fee"`

	ActionType string   `bun:"-"`
	Payer      *Address `bun:"rel:belongs-to"`
	Tx         *Tx      `bun:"rel:belongs-to"`
}

func (Fee) TableName

func (Fee) TableName() string

type FeeSummary added in v1.1.0

type FeeSummary struct {
	Asset     string `bun:"asset"`
	Amount    string `bun:"amount"`
	MinAmount string `bun:"min_amount"`
	MaxAmount string `bun:"max_amount"`
	FeeCount  int64  `bun:"fee_count"`
}

type IAction

type IAction interface {
	storage.Table[*Action]

	ByTxId(ctx context.Context, txId uint64, limit, offset int) ([]Action, error)
	ByBlock(ctx context.Context, height pkgTypes.Level, limit, offset int) ([]ActionWithTx, error)
	ByAddress(ctx context.Context, addressId uint64, filters AddressActionsFilter) ([]AddressAction, error)
	ByRollup(ctx context.Context, rollupId uint64, limit, offset int, sort storage.SortOrder) ([]RollupAction, error)
	ByRollupAndBridge(ctx context.Context, rollupId uint64, fltrs RollupAndBridgeActionsFilter) ([]ActionWithTx, error)
}

type IAddress

type IAddress interface {
	storage.Table[*Address]

	ByHash(ctx context.Context, hash string) (Address, error)
	ListWithBalance(ctx context.Context, fltrs AddressListFilter) ([]Address, error)
}

type IApp added in v1.2.0

type IApp interface {
	storage.Table[*App]

	Leaderboard(ctx context.Context, fltrs LeaderboardFilters) ([]AppWithStats, error)
	BySlug(ctx context.Context, slug string) (AppWithStats, error)
}

type IBalance

type IBalance interface {
	storage.Table[*Balance]
}

type IBalanceUpdate

type IBalanceUpdate interface {
	storage.Table[*BalanceUpdate]
}

type IBlock

type IBlock interface {
	storage.Table[*Block]

	Last(ctx context.Context) (Block, error)
	ByHeight(ctx context.Context, height pkgTypes.Level, withStats bool) (Block, error)
	ByHash(ctx context.Context, hash []byte) (Block, error)
	ByProposer(ctx context.Context, proposerId uint64, limit, offset int, order storage.SortOrder) ([]Block, error)
	ListWithStats(ctx context.Context, limit, offset uint64, order storage.SortOrder) ([]*Block, error)
	ByIdWithRelations(ctx context.Context, id uint64) (Block, error)
}

type IBlockSignature

type IBlockSignature interface {
	storage.Table[*BlockSignature]

	LevelsByValidator(ctx context.Context, validatorId uint64, startHeight pkgTypes.Level) ([]pkgTypes.Level, error)
}

type IBlockStats

type IBlockStats interface {
	ByHeight(ctx context.Context, height pkgTypes.Level) (stats BlockStats, err error)
}

type IBridge

type IBridge interface {
	storage.Table[*Bridge]

	ByAddress(ctx context.Context, addressId uint64) (Bridge, error)
	ByRollup(ctx context.Context, rollupId uint64, limit, offset int) ([]Bridge, error)
	ByRoles(ctx context.Context, addressId uint64, limit, offset int) ([]Bridge, error)
	ListWithAddress(ctx context.Context, limit, offset int) ([]Bridge, error)
	ById(ctx context.Context, id uint64) (Bridge, error)
}

type IConstant

type IConstant interface {
	Get(ctx context.Context, module types.ModuleName, name string) (Constant, error)
	ByModule(ctx context.Context, module types.ModuleName) ([]Constant, error)
	All(ctx context.Context) ([]Constant, error)
	IsNoRows(err error) bool
}

type IDeposit added in v1.1.0

type IDeposit interface {
	storage.Table[*Deposit]

	ByBridgeId(ctx context.Context, bridgeId uint64, limit, offset int, sort storage.SortOrder) ([]Deposit, error)
	ByRollupId(ctx context.Context, rollupId uint64, limit, offset int, sort storage.SortOrder) ([]Deposit, error)
}

type IFee

type IFee interface {
	storage.Table[*Fee]

	ByTxId(ctx context.Context, id uint64, limit, offset int) ([]Fee, error)
	ByPayerId(ctx context.Context, id uint64, limit, offset int, sort storage.SortOrder) ([]Fee, error)
}

type IRollup

type IRollup interface {
	sdk.Table[*Rollup]

	ActionsByHeight(ctx context.Context, height types.Level, limit, offset int) ([]RollupAction, error)
	CountActionsByHeight(ctx context.Context, height types.Level) (int64, error)
	ActionsByTxId(ctx context.Context, txId uint64, limit, offset int) ([]RollupAction, error)
	CountActionsByTxId(ctx context.Context, txId uint64) (int64, error)
	ByHash(ctx context.Context, hash []byte) (Rollup, error)
	Addresses(ctx context.Context, rollupId uint64, limit, offset int, sort sdk.SortOrder) ([]RollupAddress, error)
	ListRollupsByAddress(ctx context.Context, addressId uint64, limit, offset int, sort sdk.SortOrder) ([]RollupAddress, error)
	ListExt(ctx context.Context, fltrs RollupListFilter) ([]Rollup, error)
}

type ISearch

type ISearch interface {
	Search(ctx context.Context, query string) ([]SearchResult, error)
}

type IState

type IState interface {
	storage.Table[*State]

	ByName(ctx context.Context, name string) (State, error)
}

type IStats

type IStats interface {
	Summary(ctx context.Context) (NetworkSummary, error)
	SummaryTimeframe(ctx context.Context, timeframe Timeframe) (NetworkSummaryWithChange, error)
	Series(ctx context.Context, timeframe Timeframe, name string, req SeriesRequest) ([]SeriesItem, error)
	RollupSeries(ctx context.Context, rollupId uint64, timeframe Timeframe, name string, req SeriesRequest) ([]SeriesItem, error)
	FeeSummary(ctx context.Context) ([]FeeSummary, error)
	TokenTransferDistribution(ctx context.Context, limit int) ([]TokenTransferDistributionItem, error)
	ActiveAddressesCount(ctx context.Context) (int64, error)
}

type ITransfer added in v1.1.0

type ITransfer interface {
	storage.Table[*Transfer]
}

type ITx

type ITx interface {
	storage.Table[*Tx]

	ByHash(ctx context.Context, hash []byte) (Tx, error)
	ByHeight(ctx context.Context, height pkgTypes.Level, limit, offset int) ([]Tx, error)
	ByAddress(ctx context.Context, addressId uint64, fltrs TxFilter) ([]Tx, error)
	Filter(ctx context.Context, fltrs TxFilter) ([]Tx, error)
}

type IValidator

type IValidator interface {
	sdk.Table[*Validator]

	ListByPower(ctx context.Context, limit, offset int, order sdk.SortOrder) ([]Validator, error)
}

type LeaderboardFilters added in v1.2.0

type LeaderboardFilters struct {
	SortField string
	Sort      storage.SortOrder
	Limit     int
	Offset    int
	Category  []types.AppCategory
}

type Listener

type Listener interface {
	io.Closer

	Subscribe(ctx context.Context, channels ...string) error
	Listen() chan *pq.Notification
}

type ListenerFactory

type ListenerFactory interface {
	CreateListener() Listener
}

type NetworkSummary

type NetworkSummary struct {
	DataSize     int64           `bun:"data_size"`
	TPS          float64         `bun:"tps"`
	BPS          float64         `bun:"bps"`
	RBPS         float64         `bun:"rbps"`
	Fee          decimal.Decimal `bun:"fee"`
	Supply       decimal.Decimal `bun:"supply"`
	BlockTime    float64         `bun:"block_time"`
	TxCount      int64           `bun:"tx_count"`
	BytesInBlock int64           `bun:"bytes_in_block"`
}

type NetworkSummaryWithChange

type NetworkSummaryWithChange struct {
	DataSize        int64   `bun:"data_size"`
	DataSizePct     float64 `bun:"data_size_pct"`
	TPS             float64 `bun:"tps"`
	TPSPct          float64 `bun:"tps_pct"`
	BPS             float64 `bun:"bps"`
	BPSPct          float64 `bun:"bps_pct"`
	RBPS            float64 `bun:"rbps"`
	RBPSPct         float64 `bun:"rbps_pct"`
	BlockTime       float64 `bun:"block_time"`
	BlockTimePct    float64 `bun:"block_time_pct"`
	TxCount         int64   `bun:"tx_count"`
	TxCountPct      float64 `bun:"tx_count_pct"`
	BytesInBlock    int64   `bun:"bytes_in_block"`
	BytesInBlockPct float64 `bun:"bytes_in_block_pct"`
}

type Notificator

type Notificator interface {
	Notify(ctx context.Context, channel string, payload string) error
}

type Rollup

type Rollup struct {
	bun.BaseModel `bun:"rollup" comment:"Table with rollups"`

	Id           uint64      `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	AstriaId     []byte      `bun:"astria_id,unique:rollup_id"  comment:"Astria rollup identity"`
	FirstHeight  types.Level `bun:"first_height"                comment:"Block number of the first rollup occurrence"`
	ActionsCount int64       `bun:"actions_count"               comment:"Count of actions in which the rollup was involved"`
	BridgeCount  int64       `bun:"bridge_count"                comment:"Count of connected bridges"`
	Size         int64       `bun:"size"                        comment:"Count bytes which was saved in the rollup"`
}

func (Rollup) String

func (r Rollup) String() string

func (Rollup) TableName

func (Rollup) TableName() string

TableName -

type RollupAction

type RollupAction struct {
	bun.BaseModel `bun:"rollup_action" comment:"Table with rollup actions"`

	RollupId   uint64           `bun:"rollup_id,pk"                 comment:"Rollup internal id"`
	ActionId   uint64           `bun:"action_id,pk"                 comment:"Action internal id"`
	Time       time.Time        `bun:"time,notnull,pk"              comment:"Action time"`
	ActionType types.ActionType `bun:"action_type,type:action_type" comment:"Action type"`
	Height     pkgTypes.Level   `bun:"height"                       comment:"Action block height"`
	TxId       uint64           `bun:"tx_id"                        comment:"Transaction internal id"`
	Size       int64            `bun:"size"                         comment:"Count bytes which was pushed to the rollup"`

	Action *Action `bun:"rel:belongs-to,join:action_id=id"`
	Rollup *Rollup `bun:"rel:belongs-to,join:rollup_id=id"`
	Tx     *Tx     `bun:"rel:belongs-to,join:tx_id=id"`
}

func (RollupAction) TableName

func (RollupAction) TableName() string

type RollupAddress

type RollupAddress struct {
	bun.BaseModel `bun:"rollup_address" comment:"Table with rollup addresses"`

	RollupId  uint64      `bun:"rollup_id,pk"  comment:"Rollup internal id"`
	AddressId uint64      `bun:"address_id,pk" comment:"Address internal id"`
	Height    types.Level `bun:"height"        comment:"Block height of the first sequence action"`

	Address *Address `bun:"rel:belongs-to,join:address_id=id"`
	Rollup  *Rollup  `bun:"rel:belongs-to,join:rollup_id=id"`
}

func (RollupAddress) String

func (r RollupAddress) String() string

func (RollupAddress) TableName

func (RollupAddress) TableName() string

type RollupAndBridgeActionsFilter

type RollupAndBridgeActionsFilter struct {
	Limit         int
	Offset        int
	Sort          storage.SortOrder
	RollupActions bool
	BridgeActions bool
	ActionTypes   types.ActionTypeMask
	From          time.Time
	To            time.Time
}

type RollupListFilter

type RollupListFilter struct {
	Limit     int
	Offset    int
	SortField string
	SortOrder sdk.SortOrder
}

type RollupSummary

type RollupSummary struct {
	ActionsCount int64 `bun:"actions_count"`
	Size         int64 `bun:"size"`
	AvgSize      int64 `bun:"avg_size"`
	MinSize      int64 `bun:"min_size"`
	MaxSize      int64 `bun:"max_size"`
}

type SearchResult

type SearchResult struct {
	Id    uint64 `bun:"id"`
	Value string `bun:"value"`
	Type  string `bun:"type"`
}

type SeriesItem

type SeriesItem struct {
	Time  time.Time `bun:"ts"`
	Value string    `bun:"value"`
	Max   string    `bun:"max"`
	Min   string    `bun:"min"`
}

type SeriesRequest

type SeriesRequest struct {
	From time.Time
	To   time.Time
}

func NewSeriesRequest

func NewSeriesRequest(from, to int64) (sr SeriesRequest)

type State

type State struct {
	bun.BaseModel `bun:"state" comment:"Current indexer state"`

	Id              uint64          `bun:",pk,autoincrement"         comment:"Unique internal identity" json:"id"`
	Name            string          `bun:",unique:state_name"        comment:"Indexer name"             json:"name"`
	LastHeight      types.Level     `bun:"last_height"               comment:"Last block height"        json:"height"`
	LastHash        []byte          `bun:"last_hash"                 comment:"Last block hash"          json:"hash"`
	LastTime        time.Time       `bun:"last_time"                 comment:"Time of last block"       json:"time"`
	ChainId         string          `bun:"chain_id"                  comment:"Astria chain id"          json:"chain_id"`
	TotalTx         int64           `bun:"total_tx"                  comment:"Transactions count"       json:"tx"`
	TotalAccounts   int64           `bun:"total_accounts"            comment:"Accounts count"           json:"accounts"`
	TotalRollups    int64           `bun:"total_rollups"             comment:"Rollups count"            json:"rollups"`
	TotalValidators int             `bun:"total_validators"          comment:"Validators count"         json:"validators"`
	TotalSupply     decimal.Decimal `bun:"total_supply,type:numeric" comment:"Total supply"             json:"supply"`
	TotalBridges    int64           `bun:"total_bridges"             comment:"Count of bridges"         json:"bridges"`
}

State -

func (State) TableName

func (State) TableName() string

TableName -

type TPS

type TPS struct {
	Low               float64
	High              float64
	Current           float64
	ChangeLastHourPct float64
}

type Timeframe

type Timeframe string
const (
	TimeframeHour  Timeframe = "hour"
	TimeframeDay   Timeframe = "day"
	TimeframeWeek  Timeframe = "week"
	TimeframeMonth Timeframe = "month"
)

type TokenTransferDistributionItem added in v1.1.0

type TokenTransferDistributionItem struct {
	Asset          string `bun:"asset"`
	Amount         string `bun:"amount"`
	TransfersCount int64  `bun:"transfers_count"`
}

type Transaction

type Transaction interface {
	sdk.Transaction

	SaveActions(ctx context.Context, actions ...*Action) error
	SaveAddressActions(ctx context.Context, actions ...*AddressAction) error
	SaveAddresses(ctx context.Context, addresses ...*Address) (int64, error)
	SaveBalances(ctx context.Context, balances ...Balance) error
	SaveBalanceUpdates(ctx context.Context, updates ...BalanceUpdate) error
	SaveBlockSignatures(ctx context.Context, signs ...BlockSignature) error
	SaveBridges(ctx context.Context, bridges ...*Bridge) (int64, error)
	SaveConstants(ctx context.Context, constants ...Constant) error
	SaveRollupActions(ctx context.Context, actions ...*RollupAction) error
	SaveRollupAddresses(ctx context.Context, addresses ...*RollupAddress) error
	SaveRollups(ctx context.Context, rollups ...*Rollup) (int64, error)
	SaveTransactions(ctx context.Context, txs ...*Tx) error
	SaveValidators(ctx context.Context, validators ...*Validator) error
	SaveFees(ctx context.Context, fees ...*Fee) error
	SaveTransfers(ctx context.Context, transfers ...*Transfer) error
	SaveDeposits(ctx context.Context, deposits ...*Deposit) error
	SaveApp(ctx context.Context, app *App) error
	UpdateApp(ctx context.Context, app *App) error
	DeleteApp(ctx context.Context, appId uint64) error
	RetentionBlockSignatures(ctx context.Context, height types.Level) error

	RollbackActions(ctx context.Context, height types.Level) (actions []Action, err error)
	RollbackAddressActions(ctx context.Context, height types.Level) (addrActions []AddressAction, err error)
	RollbackAddresses(ctx context.Context, height types.Level) (address []Address, err error)
	RollbackBalances(ctx context.Context, ids []uint64) error
	RollbackBalanceUpdates(ctx context.Context, height types.Level) ([]BalanceUpdate, error)
	RollbackBlockSignatures(ctx context.Context, height types.Level) (err error)
	RollbackBlockStats(ctx context.Context, height types.Level) (stats BlockStats, err error)
	RollbackBlock(ctx context.Context, height types.Level) error
	RollbackBridges(ctx context.Context, height types.Level) (int, error)
	RollbackRollupActions(ctx context.Context, height types.Level) (rollupActions []RollupAction, err error)
	RollbackRollupAddresses(ctx context.Context, height types.Level) (err error)
	RollbackRollups(ctx context.Context, height types.Level) ([]Rollup, error)
	RollbackTxs(ctx context.Context, height types.Level) (txs []Tx, err error)
	RollbackValidators(ctx context.Context, height types.Level) (err error)
	RollbackFees(ctx context.Context, height types.Level) (err error)
	RollbackDeposits(ctx context.Context, height types.Level) (err error)
	RollbackTransfers(ctx context.Context, height types.Level) (err error)
	UpdateAddresses(ctx context.Context, address ...*Address) error
	UpdateConstants(ctx context.Context, constants ...*Constant) error
	UpdateRollups(ctx context.Context, rollups ...*Rollup) error

	LastBlock(ctx context.Context) (block Block, err error)
	State(ctx context.Context, name string) (state State, err error)
	LastNonce(ctx context.Context, id uint64) (uint32, error)
	GetProposerId(ctx context.Context, address string) (uint64, error)
	GetRollup(ctx context.Context, rollupId []byte) (Rollup, error)
	Validators(ctx context.Context) ([]Validator, error)
	GetBridgeIdByAddressId(ctx context.Context, id uint64) (uint64, error)
	GetAddressId(ctx context.Context, hash string) (uint64, error)
	RefreshLeaderboard(ctx context.Context) error
}

type Transfer added in v1.1.0

type Transfer struct {
	bun.BaseModel `bun:"transfer" comment:"Table with asset transfers"`

	Id            uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	Height        pkgTypes.Level  `bun:"height,notnull"              comment:"The number (height) of this block"`
	Time          time.Time       `bun:"time,pk,notnull"             comment:"The time of block"`
	Asset         string          `bun:"asset"                       comment:"Transfer asset"`
	Amount        decimal.Decimal `bun:"amount,type:numeric"         comment:"Transfer amount"`
	SourceId      uint64          `bun:"src_id"                      comment:"Who made transfer"`
	DestinationId uint64          `bun:"dest_id"                     comment:"Who receive transfer"`

	Source      *Address `bun:"rel:belongs-to"`
	Destination *Address `bun:"rel:belongs-to"`
}

func (Transfer) TableName added in v1.1.0

func (Transfer) TableName() string

type Tx

type Tx struct {
	bun.BaseModel `bun:"tx" comment:"Table with transactions"`

	Id           uint64         `bun:"id,autoincrement,pk,notnull" comment:"Unique internal id"`
	Height       pkgTypes.Level `bun:",notnull"                    comment:"The number (height) of this block"`
	Time         time.Time      `bun:"time,pk,notnull"             comment:"The time of block"`
	Position     int64          `bun:"position"                    comment:"Position in block"`
	ActionsCount int64          `bun:"actions_count"               comment:"Actions count in transaction"`
	Status       types.Status   `bun:"status,type:status"          comment:"Transaction status"`

	Error       string     `bun:"error,type:text"     comment:"Error string if failed"`
	Codespace   string     `bun:"codespace,type:text" comment:"Codespace"`
	SignerId    uint64     `bun:"signer_id"           comment:"Signer internal identity"`
	ActionTypes types.Bits `bun:"action_types"        comment:"Bit mask for action types contained in tx"`
	Nonce       uint32     `bun:"nonce"               comment:"Nonce"`
	Hash        []byte     `bun:"hash"                comment:"Transaction hash"`
	Signature   []byte     `bun:"signature"           comment:"Signature"`

	Actions   []Action `bun:"rel:has-many,join:id=tx_id"`
	Signer    *Address `bun:"rel:belongs-to"`
	BytesSize int64    `bun:"-"`
}

Tx -

func (Tx) TableName

func (Tx) TableName() string

TableName -

type TxCountForLast24hItem

type TxCountForLast24hItem struct {
	Time    time.Time `bun:"ts"`
	TxCount int64     `bun:"tx_count"`
	TPS     float64   `bun:"tps"`
}

type TxFilter

type TxFilter struct {
	Limit       int
	Offset      int
	Sort        storage.SortOrder
	Status      []string
	ActionTypes types.ActionTypeMask
	Height      uint64
	TimeFrom    time.Time
	TimeTo      time.Time
	WithActions bool
}

type Validator

type Validator struct {
	bun.BaseModel `bun:"validator" comment:"Table with validators"`

	Id         uint64          `bun:"id,pk,notnull,autoincrement"                comment:"Unique internal identity"`
	Address    string          `bun:"address,unique:validator_address,type:text" comment:"Validator address"`
	PubkeyType string          `bun:"pubkey_type,type:text"                      comment:"Validator public key type"`
	PubKey     []byte          `bun:"pubkey,unique:validator_pubkey"             comment:"Validator public key"`
	Name       string          `bun:"name,type:text"                             comment:"Human-readable name for the validator"`
	Power      decimal.Decimal `bun:"power,type:numeric"                         comment:"Validator power"`
	Height     pkgTypes.Level  `bun:"height"                                     comment:"Height when validator was created"`
}

func (Validator) TableName

func (Validator) TableName() string

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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