storage

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelHead = "head"
	ChannelTx   = "tx"
)
View Source
const (
	PriceTimeframeMinute = "1m"
	PriceTimeframeHour   = "1h"
	PriceTimeframeDay    = "1d"
)
View Source
const (
	SeriesBlobsSize     = "blobs_size"
	SeriesTPS           = "tps"
	SeriesBPS           = "bps"
	SeriesFee           = "fee"
	SeriesSupplyChange  = "supply_change"
	SeriesBlockTime     = "block_time"
	SeriesTxCount       = "tx_count"
	SeriesEventsCount   = "events_count"
	SeriesGasPrice      = "gas_price"
	SeriesGasUsed       = "gas_used"
	SeriesGasLimit      = "gas_limit"
	SeriesGasEfficiency = "gas_efficiency"
	SeriesNsPfbCount    = "pfb_count"
	SeriesNsSize        = "size"
)
View Source
const (
	ViewBlockStatsByMinute    = "block_stats_by_minute"
	ViewBlockStatsByHour      = "block_stats_by_hour"
	ViewBlockStatsByDay       = "block_stats_by_day"
	ViewBlockStatsByWeek      = "block_stats_by_week"
	ViewBlockStatsByMonth     = "block_stats_by_month"
	ViewBlockStatsByYear      = "block_stats_by_year"
	ViewNamespaceStatsByHour  = "namespace_stats_by_hour"
	ViewNamespaceStatsByDay   = "namespace_stats_by_day"
	ViewNamespaceStatsByWeek  = "namespace_stats_by_week"
	ViewNamespaceStatsByMonth = "namespace_stats_by_month"
	ViewNamespaceStatsByYear  = "namespace_stats_by_year"
)

Variables

View Source
var (
	ErrValidation = errors.New("validation error")
)
View Source
var Models = []any{
	&State{},
	&Constant{},
	&DenomMetadata{},
	&Balance{},
	&Address{},
	&Block{},
	&BlockStats{},
	&Tx{},
	&Message{},
	&Event{},
	&Namespace{},
	&NamespaceMessage{},
	&Signer{},
	&MsgAddress{},
	&Validator{},
	&BlobLog{},
	&Price{},
	&Rollup{},
	&RollupProvider{},
}

Functions

This section is empty.

Types

type Address

type Address struct {
	bun.BaseModel `bun:"address" comment:"Table with celestia 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."`
	LastHeight types.Level `bun:"last_height"                 comment:"Block number of the last address occurrence."`
	Hash       []byte      `bun:"hash"                        comment:"Address hash."`
	Address    string      `bun:"address,unique:address_idx"  comment:"Human-readable address."`

	Balance Balance `bun:"rel:has-one,join:id=id"`
}

Address -

func (Address) String

func (address Address) String() string

func (Address) TableName

func (Address) TableName() string

TableName -

type AddressListFilter

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

type AddressMessageWithTx added in v1.2.0

type AddressMessageWithTx struct {
	bun.BaseModel `bun:"message,alias:message"`

	MsgAddress
	Msg *Message `bun:"rel:belongs-to,join:msg_id=id"`
	Tx  *Tx      `bun:"rel:belongs-to,join:msg__tx_id=id"`
}

type AddressMsgsFilter

type AddressMsgsFilter struct {
	Limit        int
	Offset       int
	Sort         storage.SortOrder
	MessageTypes []string
}

type AddressWithType

type AddressWithType struct {
	Address

	Type types.MsgAddressType
}

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 BlobLog added in v1.2.0

type BlobLog struct {
	bun.BaseModel `bun:"blob_log" comment:"Table with flatted blob entities."`

	Id          uint64      `bun:"id,pk,autoincrement" comment:"Unique internal identity"`
	Time        time.Time   `bun:"time,notnull,pk"     comment:"Message time"`
	Height      types.Level `bun:"height"              comment:"Message block height"`
	Size        int64       `bun:"size"                comment:"Blob size"`
	Commitment  string      `bun:"commitment"          comment:"Blob commitment"`
	ContentType string      `bun:"content_type"        comment:"Blob content type"`

	SignerId    uint64 `bun:"signer_id"    comment:"Blob signer identity"`
	NamespaceId uint64 `bun:"namespace_id" comment:"Namespace internal id"`
	MsgId       uint64 `bun:"msg_id"       comment:"Message id"`
	TxId        uint64 `bun:"tx_id"        comment:"Transaction id"`

	Message   *Message   `bun:"rel:belongs-to,join:msg_id=id"`
	Namespace *Namespace `bun:"rel:belongs-to,join:namespace_id=id"`
	Tx        *Tx        `bun:"rel:belongs-to,join:tx_id=id"`
	Signer    *Address   `bun:"rel:belongs-to,join:signer_id=id"`
}

func (BlobLog) TableName added in v1.2.0

func (BlobLog) TableName() string

type BlobLogFilters added in v1.2.0

type BlobLogFilters struct {
	Limit  int
	Offset int
	Sort   sdk.SortOrder
	SortBy string
}

type Block

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

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

	MessageTypes types.MsgTypeBits `bun:"message_types,type:bit(74)" comment:"Bit mask with containing messages"`

	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"`

	ChainId         string    `bun:"-"` // internal field for filling state
	ProposerAddress string    `bun:"-"` // internal field for proposer
	Addresses       []Address `bun:"-"` // internal field for balance passing

	Txs      []Tx       `bun:"rel:has-many"`
	Events   []Event    `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 BlockStats

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

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

	TxCount       int64           `bun:"tx_count"         comment:"Count of transactions in block"                          stats:"func:min max sum avg"`
	EventsCount   int64           `bun:"events_count"     comment:"Count of events in begin and end of block"               stats:"func:min max sum avg"`
	BlobsSize     int64           `bun:"blobs_size"       comment:"Summary blocks size from pay for blob"                   stats:"func:min max sum avg"`
	BlockTime     uint64          `bun:"block_time"       comment:"Time in milliseconds between current and previous block" stats:"func:min max sum avg"`
	GasLimit      int64           `bun:"gas_limit"        comment:"Total gas limit in the block"`
	GasUsed       int64           `bun:"gas_used"         comment:"Total gas used in the block"`
	SupplyChange  decimal.Decimal `bun:",type:numeric"    comment:"Change of total supply in the block"                     stats:"func:min max sum avg"`
	InflationRate decimal.Decimal `bun:",type:numeric"    comment:"Inflation rate"                                          stats:"func:min max avg"`
	Fee           decimal.Decimal `bun:"fee,type:numeric" comment:"Summary block fee"                                       stats:"func:min max sum avg"`
	BytesInBlock  int64           `bun:"bytes_in_block"   comment:"Size of all transactions in bytes"                       stats:"func:min max sum avg"`

	MessagesCounts map[types.MsgType]int64 `bun:"-"`
}

func (BlockStats) TableName

func (BlockStats) TableName() string

type ByGasPrice added in v1.1.0

type ByGasPrice []Gas

func (ByGasPrice) Len added in v1.1.0

func (gp ByGasPrice) Len() int

func (ByGasPrice) Less added in v1.1.0

func (gp ByGasPrice) Less(i, j int) bool

func (ByGasPrice) Swap added in v1.1.0

func (gp ByGasPrice) Swap(i, j int)

type Constant

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

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

func (Constant) TableName

func (Constant) TableName() string

type CountRequest

type CountRequest struct {
	Table string
	From  uint64
	To    uint64
}

func (CountRequest) Validate

func (req CountRequest) Validate() error

type DenomMetadata

type DenomMetadata struct {
	bun.BaseModel `bun:"table:denom_metadata" comment:"Table with celestia coins metadata."`

	Id          uint64 `bun:"id,pk,notnull,autoincrement" comment:"Internal unique identity"`
	Description string `bun:"description,type:text"       comment:"Denom description"`
	Base        string `bun:"base,type:text"              comment:"Denom base"`
	Display     string `bun:"display,type:text"           comment:"Denom display"`
	Name        string `bun:"name,type:text"              comment:"Denom name"`
	Symbol      string `bun:"symbol,type:text"            comment:"Denom symbol"`
	Uri         string `bun:"uri,type:text"               comment:"Denom uri"`

	Units []byte `bun:"units,type:bytea" comment:"Denom units information"`
}

func (DenomMetadata) TableName

func (DenomMetadata) TableName() string

type Event

type Event struct {
	bun.BaseModel `bun:"event" comment:"Table with celestia events."`

	Id       uint64          `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
	Height   pkgTypes.Level  `bun:"height,notnull"              comment:"The number (height) of this block" stats:"func:min max,filterable"`
	Time     time.Time       `bun:"time,pk,notnull"             comment:"The time of block"                 stats:"func:min max,filterable"`
	Position int64           `bun:"position"                    comment:"Position in transaction"`
	Type     types.EventType `bun:",type:event_type"            comment:"Event type"                        stats:"filterable"`
	TxId     *uint64         `bun:"tx_id"                       comment:"Transaction id"`
	Data     map[string]any  `bun:"data,type:jsonb"             comment:"Event data"`
}

Event -

func (Event) Columns

func (e Event) Columns() []string

func (Event) Flat

func (e Event) Flat() []any

func (Event) TableName

func (Event) TableName() string

TableName -

type Gas added in v1.1.0

type Gas struct {
	GasWanted int64           `bun:"gas_wanted"`
	GasUsed   int64           `bun:"gas_used"`
	Fee       decimal.Decimal `bun:"fee"`
	GasPrice  decimal.Decimal `bun:"gas_price"`
}

type HistogramCountRequest

type HistogramCountRequest struct {
	CountRequest
	Timeframe Timeframe
}

func (HistogramCountRequest) Validate

func (req HistogramCountRequest) Validate() error

type HistogramItem

type HistogramItem struct {
	Time  time.Time `bun:"bucket"`
	Value string    `bun:"value"`
}

type HistogramRequest

type HistogramRequest struct {
	SummaryRequest
	Timeframe Timeframe
}

func (HistogramRequest) Validate

func (req HistogramRequest) Validate() error

type IAddress

type IAddress interface {
	storage.Table[*Address]

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

type IBalance

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

type IBlobLog added in v1.2.0

type IBlobLog interface {
	storage.Table[*BlobLog]

	ByNamespace(ctx context.Context, nsId uint64, fltrs BlobLogFilters) ([]BlobLog, error)
	ByProviders(ctx context.Context, providers []RollupProvider, fltrs BlobLogFilters) ([]BlobLog, error)
	BySigner(ctx context.Context, signerId uint64, fltrs BlobLogFilters) ([]BlobLog, error)
}

type IBlock

type IBlock interface {
	storage.Table[*Block]

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

type IBlockStats

type IBlockStats interface {
	ByHeight(ctx context.Context, height pkgTypes.Level) (BlockStats, error)
	LastFrom(ctx context.Context, head pkgTypes.Level, limit int) ([]BlockStats, 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)
}

type IDenomMetadata

type IDenomMetadata interface {
	All(ctx context.Context) ([]DenomMetadata, error)
}

type IEvent

type IEvent interface {
	storage.Table[*Event]

	ByTxId(ctx context.Context, txId uint64) ([]Event, error)
	ByBlock(ctx context.Context, height pkgTypes.Level) ([]Event, error)
}

type IMessage

type IMessage interface {
	storage.Table[*Message]

	ByTxId(ctx context.Context, txId uint64) ([]Message, error)
	ListWithTx(ctx context.Context, filters MessageListWithTxFilters) ([]MessageWithTx, error)
	ByAddress(ctx context.Context, id uint64, filters AddressMsgsFilter) ([]AddressMessageWithTx, error)
}

type INamespace

type INamespace interface {
	storage.Table[*Namespace]

	ByNamespaceId(ctx context.Context, namespaceId []byte) ([]Namespace, error)
	ByNamespaceIdAndVersion(ctx context.Context, namespaceId []byte, version byte) (Namespace, error)
	Messages(ctx context.Context, id uint64, limit, offset int) ([]NamespaceMessage, error)
	MessagesByHeight(ctx context.Context, height pkgTypes.Level, limit, offset int) ([]NamespaceMessage, error)
	CountMessagesByHeight(ctx context.Context, height pkgTypes.Level) (int, error)
	ListWithSort(ctx context.Context, sortField string, sort sdk.SortOrder, limit, offset int) (ns []Namespace, err error)
	MessagesByTxId(ctx context.Context, txId uint64, limit, offset int) ([]NamespaceMessage, error)
	CountMessagesByTxId(ctx context.Context, txId uint64) (int, error)
	GetByIds(ctx context.Context, ids ...uint64) (ns []Namespace, err error)
}

type IPrice added in v1.2.0

type IPrice interface {
	Save(ctx context.Context, price *Price) error
	Last(ctx context.Context) (Price, error)
	Get(ctx context.Context, timeframe string, start, end int64, limit int) ([]Price, error)
}

type IRollup added in v1.2.0

type IRollup interface {
	storage.Table[*Rollup]

	Leaderboard(ctx context.Context, sortField string, sort sdk.SortOrder, limit, offset int) ([]RollupWithStats, error)
	Namespaces(ctx context.Context, rollupId uint64, limit, offset int) (namespaceIds []uint64, err error)
	Providers(ctx context.Context, rollupId uint64) (providers []RollupProvider, err error)
	Stats(ctx context.Context, rollupId uint64, timeframe, column string, req SeriesRequest) (items []HistogramItem, err error)
}

type IRollupProvider added in v1.2.0

type IRollupProvider interface {
	storage.Table[*RollupProvider]
}

type IState

type IState interface {
	storage.Table[*State]

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

type IStats

type IStats interface {
	Count(ctx context.Context, req CountRequest) (string, error)
	Summary(ctx context.Context, req SummaryRequest) (string, error)
	HistogramCount(ctx context.Context, req HistogramCountRequest) ([]HistogramItem, error)
	Histogram(ctx context.Context, req HistogramRequest) ([]HistogramItem, error)
	TPS(ctx context.Context) (TPS, error)
	TxCountForLast24h(ctx context.Context) ([]TxCountForLast24hItem, error)
	Series(ctx context.Context, timeframe Timeframe, name string, req SeriesRequest) ([]SeriesItem, error)
	NamespaceSeries(ctx context.Context, timeframe Timeframe, name string, nsId uint64, req SeriesRequest) (response []SeriesItem, err error)
}

type ITx

type ITx interface {
	storage.Table[*Tx]

	ByHash(ctx context.Context, hash []byte) (Tx, error)
	Filter(ctx context.Context, fltrs TxFilter) ([]Tx, error)
	ByIdWithRelations(ctx context.Context, id uint64) (Tx, error)
	ByAddress(ctx context.Context, addressId uint64, fltrs TxFilter) ([]Tx, error)
	Genesis(ctx context.Context, limit, offset int, sortOrder storage.SortOrder) ([]Tx, error)
	Gas(ctx context.Context, height pkgTypes.Level) ([]Gas, error)
}

type IValidator

type IValidator interface {
	storage.Table[*Validator]

	ByAddress(ctx context.Context, address string) (Validator, error)
}

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 Message

type Message struct {
	bun.BaseModel `bun:"message" comment:"Table with celestia messages."`

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

	Namespace []Namespace       `bun:"m2m:namespace_message,join:Message=Namespace"`
	Validator *Validator        `bun:"rel:belongs-to"`
	Addresses []AddressWithType `bun:"-"`
	BlobLogs  []*BlobLog        `bun:"-"`
}

Message -

func (Message) TableName

func (Message) TableName() string

TableName -

type MessageListWithTxFilters added in v1.0.4

type MessageListWithTxFilters struct {
	Height               pkgTypes.Level
	Limit                int
	Offset               int
	ExcludedMessageTypes []string
	MessageTypes         []string
}

type MessageWithTx added in v1.0.4

type MessageWithTx struct {
	bun.BaseModel `bun:"message,alias:message"`

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

type MsgAddress

type MsgAddress struct {
	bun.BaseModel `bun:"msg_address" comment:"Table with relation tx to address"`

	AddressId uint64               `bun:"address_id,pk"             comment:"Address internal id"`
	MsgId     uint64               `bun:"msg_id,pk"                 comment:"Message internal id"`
	Type      types.MsgAddressType `bun:",pk,type:msg_address_type" comment:"The reason why address link to transaction"`

	Address *Address `bun:"rel:belongs-to,join:address_id=id"`
	Msg     *Message `bun:"rel:belongs-to,join:msg_id=id"`
}

func (MsgAddress) String added in v1.0.4

func (m MsgAddress) String() string

func (MsgAddress) TableName

func (MsgAddress) TableName() string

type Namespace

type Namespace struct {
	bun.BaseModel `bun:"namespace" comment:"Table with celestia namespaces."`

	Id              uint64      `bun:"id,pk,autoincrement"                          comment:"Unique internal identity"`
	FirstHeight     types.Level `bun:"first_height,notnull"                         comment:"Block height of the first message changing the namespace"`
	LastHeight      types.Level `bun:"last_height,notnull"                          comment:"Block height of the last message changing the namespace"`
	Version         byte        `bun:"version,unique:namespace_id_version_idx"      comment:"Namespace version"`
	NamespaceID     []byte      `bun:"namespace_id,unique:namespace_id_version_idx" comment:"Namespace identity"`
	Size            int64       `bun:"size"                                         comment:"Blobs size"`
	PfbCount        int64       `bun:"pfb_count"                                    comment:"Count of pay for blobs messages for the namespace"`
	BlobsCount      int64       `bun:"blobs_count"                                  comment:"Count of blobs sent to namespace"`
	Reserved        bool        `bun:"reserved,default:false"                       comment:"If namespace is reserved flag is true"`
	LastMessageTime time.Time   `bun:"last_message_time"                            comment:"Time when last pay for blob was sent"`
}

Namespace -

func (Namespace) Copy added in v1.3.0

func (ns Namespace) Copy() *Namespace

func (Namespace) Hash

func (ns Namespace) Hash() string

func (Namespace) String

func (ns Namespace) String() string

func (Namespace) TableName

func (Namespace) TableName() string

TableName -

type NamespaceMessage

type NamespaceMessage struct {
	bun.BaseModel `bun:"namespace_message" comment:"Table with relation messages to namespace."`

	NamespaceId uint64 `bun:"namespace_id,pk" comment:"Namespace internal id"`
	MsgId       uint64 `bun:"msg_id,pk"       comment:"Message id"`
	TxId        uint64 `bun:"tx_id"           comment:"Transaction id"`

	Time   time.Time   `bun:"time,notnull,pk" comment:"Message time"`
	Height types.Level `bun:"height"          comment:"Message block height"`
	Size   uint64      `bun:"size"            comment:"Total namespace size change due to message"`

	Message   *Message   `bun:"rel:belongs-to,join:msg_id=id"`
	Namespace *Namespace `bun:"rel:belongs-to,join:namespace_id=id"`
	Tx        *Tx        `bun:"rel:belongs-to,join:tx_id=id"`
}

func (NamespaceMessage) TableName

func (NamespaceMessage) TableName() string

type Notificator

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

type Price added in v1.2.0

type Price struct {
	bun.BaseModel `bun:"price" comment:"Table with TIA price"`

	Time  time.Time       `bun:"time,pk"             comment:"Time of candles"`
	Open  decimal.Decimal `bun:"open,,type:numeric"  comment:"Open price"`
	High  decimal.Decimal `bun:"high,,type:numeric"  comment:"High price"`
	Low   decimal.Decimal `bun:"low,,type:numeric"   comment:"Low price"`
	Close decimal.Decimal `bun:"close,,type:numeric" comment:"Close price"`
}

func (Price) TableName added in v1.2.0

func (Price) TableName() string

TableName -

type Rollup added in v1.2.0

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

	Id          uint64 `bun:"id,pk,autoincrement" comment:"Unique internal identity"`
	Name        string `bun:"name"                comment:"Rollup's name"`
	Description string `bun:"description"         comment:"Rollup's description"`
	Website     string `bun:"website"             comment:"Website"`
	GitHub      string `bun:"github"              comment:"Github repository"`
	Twitter     string `bun:"twitter"             comment:"Twitter account"`

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

Rollup -

func (Rollup) IsEmpty added in v1.2.0

func (r Rollup) IsEmpty() bool

func (Rollup) TableName added in v1.2.0

func (Rollup) TableName() string

TableName -

type RollupProvider added in v1.2.0

type RollupProvider struct {
	bun.BaseModel `bun:"rollup_provider" comment:"Table with data providers for rollups."`

	RollupId    uint64 `bun:"rollup_id,pk"    comment:"Unique internal rollup identity"`
	NamespaceId uint64 `bun:"namespace_id,pk" comment:"Namespace identity. May be NULL"`
	AddressId   uint64 `bun:"address_id,pk"   comment:"Celestia address of data provider"`
}

RollupProvider -

func (RollupProvider) TableName added in v1.2.0

func (RollupProvider) TableName() string

TableName -

type RollupWithStats added in v1.2.0

type RollupWithStats struct {
	Rollup

	Size           int64     `bun:"size"`
	BlobsCount     int64     `bun:"blobs_count"`
	LastActionTime time.Time `bun:"last_time"`
}

type SeriesItem added in v1.1.0

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

type SeriesRequest added in v1.1.0

type SeriesRequest struct {
	From uint64
	To   uint64
}

type Signer

type Signer struct {
	bun.BaseModel `bun:"signer" comment:"Table with signers tx"`

	AddressId uint64 `bun:"address_id,pk" comment:"Address internal id"`
	TxId      uint64 `bun:"tx_id,pk"      comment:"Transaction internal id"`

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

func (Signer) TableName

func (Signer) TableName() string

type State

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

	Id              uint64          `bun:",pk,autoincrement"         comment:"Unique internal identity"`
	Name            string          `bun:",unique:state_name"        comment:"Indexer name"`
	LastHeight      types.Level     `bun:"last_height"               comment:"Last block height"`
	LastHash        []byte          `bun:"last_hash"                 comment:"Last block hash"`
	LastTime        time.Time       `bun:"last_time"                 comment:"Time of last block"`
	ChainId         string          `bun:"chain_id"                  comment:"Celestia chain id"`
	TotalTx         int64           `bun:"total_tx"                  comment:"Transactions count in celestia"`
	TotalAccounts   int64           `bun:"total_accounts"            comment:"Accounts count in celestia"`
	TotalNamespaces int64           `bun:"total_namespaces"          comment:"Namespaces count in celestia"`
	TotalBlobsSize  int64           `bun:"total_blobs_size"          comment:"Total blobs size"`
	TotalSupply     decimal.Decimal `bun:"total_supply,type:numeric" comment:"Total supply in celestia"`
	TotalFee        decimal.Decimal `bun:"total_fee,type:numeric"    comment:"Total paid fee"`
}

State -

func (State) TableName

func (State) TableName() string

TableName -

type SummaryRequest

type SummaryRequest struct {
	CountRequest
	Column   string
	Function string
}

func (SummaryRequest) Validate

func (req SummaryRequest) Validate() error

type TPS added in v1.1.0

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"
	TimeframeYear  Timeframe = "year"
)

type Transaction

type Transaction interface {
	sdk.Transaction

	SaveConstants(ctx context.Context, constants ...Constant) error
	SaveTransactions(ctx context.Context, txs ...Tx) error
	SaveNamespaces(ctx context.Context, namespaces ...*Namespace) (int64, error)
	SaveAddresses(ctx context.Context, addresses ...*Address) (int64, error)
	SaveBalances(ctx context.Context, balances ...Balance) error
	SaveMessages(ctx context.Context, msgs ...*Message) error
	SaveSigners(ctx context.Context, addresses ...Signer) error
	SaveMsgAddresses(ctx context.Context, addresses ...MsgAddress) error
	SaveNamespaceMessage(ctx context.Context, nsMsgs ...NamespaceMessage) error
	SaveBlobLogs(ctx context.Context, logs ...BlobLog) error
	SaveValidators(ctx context.Context, validators ...*Validator) error
	SaveEvents(ctx context.Context, events ...Event) error
	LastBlock(ctx context.Context) (block Block, err error)
	State(ctx context.Context, name string) (state State, err error)
	Namespace(ctx context.Context, id uint64) (ns Namespace, err error)
	SaveRollup(ctx context.Context, rollup *Rollup) error
	UpdateRollup(ctx context.Context, rollup *Rollup) error
	SaveProviders(ctx context.Context, providers ...RollupProvider) error

	RollbackBlock(ctx context.Context, height types.Level) error
	RollbackBlockStats(ctx context.Context, height types.Level) (stats BlockStats, err error)
	RollbackAddresses(ctx context.Context, height types.Level) (address []Address, err error)
	RollbackTxs(ctx context.Context, height types.Level) (txs []Tx, err error)
	RollbackEvents(ctx context.Context, height types.Level) (events []Event, err error)
	RollbackMessages(ctx context.Context, height types.Level) (msgs []Message, err error)
	RollbackNamespaceMessages(ctx context.Context, height types.Level) (msgs []NamespaceMessage, err error)
	RollbackNamespaces(ctx context.Context, height types.Level) (ns []Namespace, err error)
	RollbackValidators(ctx context.Context, height types.Level) (err error)
	RollbackBlobLog(ctx context.Context, height types.Level) error
	RollbackSigners(ctx context.Context, txIds []uint64) (err error)
	RollbackMessageAddresses(ctx context.Context, msgIds []uint64) (err error)
	DeleteBalances(ctx context.Context, ids []uint64) error
	LastAddressAction(ctx context.Context, address []byte) (uint64, error)
	LastNamespaceMessage(ctx context.Context, nsId uint64) (msg NamespaceMessage, err error)
	GetProposerId(ctx context.Context, address string) (uint64, error)
	DeleteProviders(ctx context.Context, rollupId uint64) error
	DeleteRollup(ctx context.Context, rollupId uint64) error
}

type Tx

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

	Id            uint64          `bun:"id,autoincrement,pk,notnull" comment:"Unique internal id"`
	Height        pkgTypes.Level  `bun:",notnull"                    comment:"The number (height) of this block"                 stats:"func:min max,filterable"`
	Time          time.Time       `bun:"time,pk,notnull"             comment:"The time of block"                                 stats:"func:min max,filterable"`
	Position      int64           `bun:"position"                    comment:"Position in block"`
	GasWanted     int64           `bun:"gas_wanted"                  comment:"Gas wanted"                                        stats:"func:min max sum avg"`
	GasUsed       int64           `bun:"gas_used"                    comment:"Gas used"                                          stats:"func:min max sum avg"`
	TimeoutHeight uint64          `bun:"timeout_height"              comment:"Block height until which the transaction is valid" stats:"func:min max avg"`
	EventsCount   int64           `bun:"events_count"                comment:"Events count in transaction"                       stats:"func:min max sum avg"`
	MessagesCount int64           `bun:"messages_count"              comment:"Messages count in transaction"                     stats:"func:min max sum avg"`
	Fee           decimal.Decimal `bun:"fee,type:numeric"            comment:"Paid fee"                                          stats:"func:min max sum avg"`
	Status        types.Status    `bun:"status,type:status"          comment:"Transaction status"                                stats:"filterable"`

	Error        string            `bun:"error,type:text"            comment:"Error string if failed"`
	Codespace    string            `bun:"codespace,type:text"        comment:"Codespace"                                    stats:"filterable"`
	Hash         []byte            `bun:"hash"                       comment:"Transaction hash"`
	Memo         string            `bun:"memo,type:text"             comment:"Note or comment to send with the transaction"`
	MessageTypes types.MsgTypeBits `bun:"message_types,type:bit(74)" comment:"Bit mask with containing messages"            stats:"filterable"`

	Messages []Message `bun:"rel:has-many,join:id=tx_id"`
	Events   []Event   `bun:"rel:has-many"`
	Signers  []Address `bun:"m2m:signer,join:Tx=Address"`

	BlobsSize int64 `bun:"-"`
	BytesSize int64 `bun:"-"`
}

Tx -

func (Tx) TableName

func (Tx) TableName() string

TableName -

type TxCountForLast24hItem added in v1.1.0

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
	MessageTypes         types.MsgTypeBits
	ExcludedMessageTypes types.MsgTypeBits
	Height               uint64
	TimeFrom             time.Time
	TimeTo               time.Time
	WithMessages         bool
}

type Validator

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

	Id          uint64 `bun:"id,pk,notnull,autoincrement"                comment:"Unique internal identity"`
	Delegator   string `bun:"delegator,type:text"                        comment:"Delegator address"`
	Address     string `bun:"address,unique:address_validator,type:text" comment:"Validator address"`
	ConsAddress string `bun:"cons_address"                               comment:"Consensus address"`

	Moniker  string `bun:"moniker,type:text"  comment:"Human-readable name for the validator"`
	Website  string `bun:"website,type:text"  comment:"Website link"`
	Identity string `bun:"identity,type:text" comment:"Optional identity signature"`
	Contacts string `bun:"contacts,type:text" comment:"Contacts"`
	Details  string `bun:"details,type:text"  comment:"Detailed information about validator"`

	Rate              decimal.Decimal `bun:"rate,type:numeric"                comment:"Commission rate charged to delegators, as a fraction"`
	MaxRate           decimal.Decimal `bun:"max_rate,type:numeric"            comment:"Maximum commission rate which validator can ever charge, as a fraction"`
	MaxChangeRate     decimal.Decimal `bun:"max_change_rate,type:numeric"     comment:"Maximum daily increase of the validator commission, as a fraction"`
	MinSelfDelegation decimal.Decimal `bun:"min_self_delegation,type:numeric" comment:""`

	MsgId  uint64         `bun:"msg_id" comment:"Message id when validator was created"`
	Height pkgTypes.Level `bun:"height" comment:"Height when validator was created"`
}

func (Validator) TableName

func (Validator) TableName() string

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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