storage

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: GPL-3.0 Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	BlockNum       int    `json:"block_num"`
	BlockTimestamp int    `json:"block_timestamp"`
	Hash           string `json:"hash"`
	SpecVersion    int    `json:"spec_version"`
	Validator      string `json:"validator"`
	Finalized      bool   `json:"finalized"`
}

type DB

type DB interface {
	// GetDbInstance Get db instance, default is *gorm.DB
	GetDbInstance() any

	// FindBy Can query database all tables data
	// Query ** no prefix ** table default, option PluginPrefix can specify other plugin model
	FindBy(record interface{}, query interface{}, option *Option) (int, bool)

	// AutoMigration Only can exec plugin relate tables
	AutoMigration(model interface{}) error
	// AddIndex Add column Index
	AddIndex(model interface{}, indexName string, columns ...string) error
	// AddUniqueIndex Add column unique index
	AddUniqueIndex(model interface{}, indexName string, columns ...string) error

	// Create one record
	Create(record interface{}) error
	// Update one or more column
	Update(model interface{}, query interface{}, attr map[string]interface{}) error
	// Delete one or more record
	Delete(model interface{}, query interface{}) error

	GetBlocksByNums(c context.Context, blockNums []uint, columns string) (blocks []*Block)

	GetCurrentBlockNum(c context.Context) (uint64, error)
}

DB interface Every query can be found here https://gorm.io/docs/

type Dao

type Dao interface {
	DB
	// Find spec metadata raw
	SpecialMetadata(int) string

	// Substrate websocket rpc pool
	RPCPool() *websocket.PoolConn

	// Plugin set prefix
	SetPrefix(string)
}

type Event

type Event struct {
	Id            uint   `json:"id"`
	BlockNum      int    `json:"block_num"`
	ExtrinsicIdx  int    `json:"extrinsic_idx"`
	ModuleId      string `json:"module_id"`
	EventId       string `json:"event_id"`
	Params        []byte `json:"params"`
	ExtrinsicHash string `json:"extrinsic_hash"`
	EventIdx      int    `json:"event_idx"`
}

type EventParam

type EventParam struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

type Extrinsic

type Extrinsic struct {
	ExtrinsicIndex     string          `json:"extrinsic_index" `
	CallCode           string          `json:"call_code"`
	CallModuleFunction string          `json:"call_module_function" `
	CallModule         string          `json:"call_module"`
	Params             []byte          `json:"params"`
	AccountId          string          `json:"account_id"`
	Signature          string          `json:"signature"`
	Nonce              int             `json:"nonce"`
	Era                string          `json:"era"`
	ExtrinsicHash      string          `json:"extrinsic_hash"`
	Success            bool            `json:"success"`
	Fee                decimal.Decimal `json:"fee"`
}

type ExtrinsicParam

type ExtrinsicParam struct {
	Name  string      `json:"name"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

type Option

type Option struct {
	PluginPrefix string
	PageSize     int
	Page         int
	Order        string
}

Jump to

Keyboard shortcuts

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