Documentation ¶
Index ¶
- Constants
- Variables
- func New(ctx context.Context, mysqlDsn string) (*Dao, *DbStorage, error)
- type Dao
- func (d *Dao) AddIndex(blockNum int)
- func (d *Dao) BlockAsJson(c context.Context, block *model.ChainBlock) *model.ChainBlockJson
- func (d *Dao) BlocksReverseByNum(blockNums []int) map[int]model.ChainBlock
- func (d *Dao) ByBlockHeight(ctx context.Context, blockHeight int) ([]*EventDetail, error)
- func (d *Dao) ByID(ctx context.Context, eventID string) (*EventDetail, error)
- func (d *Dao) Close()
- func (d *Dao) CreateBlock(txn *GormDB, cb *model.ChainBlock) (err error)
- func (d *Dao) CreateEvent(txn *GormDB, event *model.ChainEvent) error
- func (d *Dao) CreateEventDetail(txn *GormDB, eventDetail *EventDetail) error
- func (d *Dao) CreateExtrinsic(c context.Context, txn *GormDB, extrinsic *model.ChainExtrinsic) error
- func (d *Dao) CreateLog(txn *GormDB, ce *model.ChainLog) error
- func (d *Dao) CreateRuntimeVersion(name string, specVersion int) int64
- func (d *Dao) DbBegin() *GormDB
- func (d *Dao) DbCommit(c *GormDB)
- func (d *Dao) DbRollback(c *GormDB)
- func (d *Dao) DropEventNotFinalizedData(blockNum int, finalized bool) bool
- func (d *Dao) DropExtrinsicNotFinalizedData(c context.Context, blockNum int, finalized bool) bool
- func (d *Dao) DropLogsNotFinalizedData(blockNum int, finalized bool) bool
- func (d *Dao) ExtrinsicsAsJson(e *model.ChainExtrinsic) *model.ChainExtrinsicJson
- func (d *Dao) GetBestBlockNum(c context.Context) (uint64, error)
- func (d *Dao) GetBlockByHash(c context.Context, hash string) *model.ChainBlock
- func (d *Dao) GetBlockByNum(blockNum int) *model.ChainBlock
- func (d *Dao) GetBlockList(page, row int) []model.ChainBlock
- func (d *Dao) GetBlockNumArr(start, end int) []int
- func (d *Dao) GetEventByBlockNum(blockNum int, where ...string) []model.ChainEventJson
- func (d *Dao) GetEventByIdx(index string) *model.ChainEvent
- func (d *Dao) GetEventList(page, row int, order string, where ...string) ([]model.ChainEvent, int)
- func (d *Dao) GetEventsByIndex(extrinsicIndex string) []model.ChainEvent
- func (d *Dao) GetExtrinsicList(c context.Context, page, row int, order string, queryWhere ...string) ([]model.ChainExtrinsic, int)
- func (d *Dao) GetExtrinsicsByBlockNum(blockNum int) []model.ChainExtrinsicJson
- func (d *Dao) GetExtrinsicsByHash(c context.Context, hash string) *model.ChainExtrinsic
- func (d *Dao) GetExtrinsicsDetailByHash(c context.Context, hash string) *model.ExtrinsicDetail
- func (d *Dao) GetExtrinsicsDetailByIndex(c context.Context, index string) *model.ExtrinsicDetail
- func (d *Dao) GetFillBestBlockNum(c context.Context) (int, error)
- func (d *Dao) GetFillFinalizedBlockNum(c context.Context) (int, error)
- func (d *Dao) GetFinalizedBlockNum(c context.Context) (uint64, error)
- func (d *Dao) GetLogByBlockNum(blockNum int) []model.ChainLogJson
- func (d *Dao) GetLogsByIndex(index string) *model.ChainLogJson
- func (d *Dao) GetMetadata(c context.Context) (map[string]string, error)
- func (d *Dao) GetNearBlock(blockNum int) *model.ChainBlock
- func (d *Dao) IncrMetadata(c context.Context, filed string, incrNum int) error
- func (d *Dao) InternalTables(blockNum int) (models []interface{})
- func (d *Dao) List(ctx context.Context) ([]*EventDetail, error)
- func (d *Dao) ListSapce() ([]models.Space, error)
- func (d *Dao) Migration(ctx context.Context)
- func (d *Dao) RuntimeVersionList() []model.RuntimeVersion
- func (d *Dao) RuntimeVersionRaw(spec int) *metadata.RuntimeRaw
- func (d *Dao) RuntimeVersionRecent() *model.RuntimeVersion
- func (d *Dao) SaveEventDetail(ctx context.Context, eventDetail *EventDetail) error
- func (d *Dao) SaveFillAlreadyBlockNum(c context.Context, blockNum int) error
- func (d *Dao) SaveFillAlreadyFinalizedBlockNum(ctx context.Context, blockNum int) error
- func (d *Dao) SaveSpace(s *models.Space) error
- func (d *Dao) SetBlockFinalized(block *model.ChainBlock)
- func (d *Dao) SetMetadata(c context.Context, metadata map[string]interface{}) error
- func (d *Dao) SetRuntimeData(specVersion int, modules string, rawData string) int64
- func (d *Dao) UpdateEventAndExtrinsic(txn *GormDB, block *model.ChainBlock, ...) error
- type DbStorage
- func (d *DbStorage) AddIndex(model interface{}, indexName string, columns ...string) error
- func (d *DbStorage) AddUniqueIndex(model interface{}, indexName string, columns ...string) error
- func (d *DbStorage) AutoMigration(model interface{}) error
- func (d *DbStorage) Create(record interface{}) error
- func (d *DbStorage) Delete(model interface{}, query interface{}) error
- func (d *DbStorage) FindBy(record interface{}, query interface{}, option *storage.Option) (int, bool)
- func (d *DbStorage) GetPrefix() string
- func (d *DbStorage) RPCPool() *websocket.PoolConn
- func (d *DbStorage) SetPrefix(prefix string)
- func (d *DbStorage) SpecialMetadata(spec int) string
- func (d *DbStorage) Update(model interface{}, query interface{}, attr map[string]interface{}) error
- type EventDetail
- type GormDB
- type IDao
Constants ¶
View Source
const ( // RedisMetadataKey = "metadata" FillAlreadyBlockNum = "fill_already_blockNum" FillFinalizedBlockNum = "fill_finalized_blockNum" MetadataBlockNum = "blockNum" MetadataFinalizedBlockNum = "finalized_blockNum" )
Variables ¶
View Source
var ( // MetadataBlockNum = "MetadataBlockNum" // MetadataFinalizedBlockNum = "MetadataFinalizedBlockNum" MetadataImplName = "MetadataImplName" MetadataSpecVersion = "MetadataSpecVersion" )
View Source
var (
DaemonAction = []string{"substrate"}
)
View Source
var SplitTableBlockNum = model.SplitTableBlockNum
Functions ¶
Types ¶
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
dao
func (*Dao) BlockAsJson ¶
func (d *Dao) BlockAsJson(c context.Context, block *model.ChainBlock) *model.ChainBlockJson
func (*Dao) BlocksReverseByNum ¶
func (d *Dao) BlocksReverseByNum(blockNums []int) map[int]model.ChainBlock
func (*Dao) ByBlockHeight ¶
func (*Dao) CreateBlock ¶
func (d *Dao) CreateBlock(txn *GormDB, cb *model.ChainBlock) (err error)
CreateBlock, mysql db transaction Check if you need to create a new table(block, extrinsic, event, log ) after created
func (*Dao) CreateEvent ¶
func (d *Dao) CreateEvent(txn *GormDB, event *model.ChainEvent) error
func (*Dao) CreateEventDetail ¶
func (d *Dao) CreateEventDetail(txn *GormDB, eventDetail *EventDetail) error
func (*Dao) CreateExtrinsic ¶
func (*Dao) CreateRuntimeVersion ¶
func (*Dao) DbRollback ¶
func (*Dao) DropEventNotFinalizedData ¶
func (*Dao) DropExtrinsicNotFinalizedData ¶
func (*Dao) DropLogsNotFinalizedData ¶
func (*Dao) ExtrinsicsAsJson ¶
func (d *Dao) ExtrinsicsAsJson(e *model.ChainExtrinsic) *model.ChainExtrinsicJson
func (*Dao) GetBlockByHash ¶
func (*Dao) GetBlockByNum ¶
func (d *Dao) GetBlockByNum(blockNum int) *model.ChainBlock
func (*Dao) GetBlockList ¶
func (d *Dao) GetBlockList(page, row int) []model.ChainBlock
func (*Dao) GetBlockNumArr ¶
func (*Dao) GetEventByBlockNum ¶
func (d *Dao) GetEventByBlockNum(blockNum int, where ...string) []model.ChainEventJson
func (*Dao) GetEventByIdx ¶
func (d *Dao) GetEventByIdx(index string) *model.ChainEvent
func (*Dao) GetEventList ¶
func (*Dao) GetEventsByIndex ¶
func (d *Dao) GetEventsByIndex(extrinsicIndex string) []model.ChainEvent
func (*Dao) GetExtrinsicList ¶
func (*Dao) GetExtrinsicsByBlockNum ¶
func (d *Dao) GetExtrinsicsByBlockNum(blockNum int) []model.ChainExtrinsicJson
func (*Dao) GetExtrinsicsByHash ¶
func (*Dao) GetExtrinsicsDetailByHash ¶
func (*Dao) GetExtrinsicsDetailByIndex ¶
func (*Dao) GetFillFinalizedBlockNum ¶
func (*Dao) GetFinalizedBlockNum ¶
func (*Dao) GetLogByBlockNum ¶
func (d *Dao) GetLogByBlockNum(blockNum int) []model.ChainLogJson
func (*Dao) GetLogsByIndex ¶
func (d *Dao) GetLogsByIndex(index string) *model.ChainLogJson
func (*Dao) GetNearBlock ¶
func (d *Dao) GetNearBlock(blockNum int) *model.ChainBlock
func (*Dao) IncrMetadata ¶
func (*Dao) InternalTables ¶
func (*Dao) RuntimeVersionList ¶
func (d *Dao) RuntimeVersionList() []model.RuntimeVersion
func (*Dao) RuntimeVersionRaw ¶
func (d *Dao) RuntimeVersionRaw(spec int) *metadata.RuntimeRaw
func (*Dao) RuntimeVersionRecent ¶
func (d *Dao) RuntimeVersionRecent() *model.RuntimeVersion
func (*Dao) SaveEventDetail ¶
func (d *Dao) SaveEventDetail(ctx context.Context, eventDetail *EventDetail) error
func (*Dao) SaveFillAlreadyBlockNum ¶
func (*Dao) SaveFillAlreadyFinalizedBlockNum ¶
func (*Dao) SetBlockFinalized ¶
func (d *Dao) SetBlockFinalized(block *model.ChainBlock)
func (*Dao) SetMetadata ¶
func (*Dao) SetRuntimeData ¶
type DbStorage ¶
type DbStorage struct { Prefix string // contains filtered or unexported fields }
func (*DbStorage) AddUniqueIndex ¶
func (*DbStorage) AutoMigration ¶
func (*DbStorage) SpecialMetadata ¶
type EventDetail ¶
type EventDetail struct { ID string `gorm:"column:id;type:varchar(256);primary_key"` // event id Name string `gorm:"column:name;type:varchar(64);index"` BlockHeight int `gorm:"column:block_height;index"` PublicKey string `gorm:"column:public_key;type:varchar(128);index"` ParentHash string `gorm:"column:parent_hash;type:varchar(128)"` RewardAddress string `gorm:"column:reward_address;type:varchar(128);index"` }
func (EventDetail) TableName ¶
func (c EventDetail) TableName() string
type IDao ¶
type IDao interface { Close() // Ping(ctx context.Context) (err error) // SetHeartBeatNow(context.Context, string) error // DaemonHeath(context.Context) map[string]bool DbBegin() *GormDB DbCommit(*GormDB) DbRollback(*GormDB) CreateBlock(*GormDB, *model.ChainBlock) (err error) UpdateEventAndExtrinsic(*GormDB, *model.ChainBlock, int, int, int, string, bool, bool) error GetNearBlock(int) *model.ChainBlock SetBlockFinalized(*model.ChainBlock) BlocksReverseByNum([]int) map[int]model.ChainBlock GetBlockByHash(context.Context, string) *model.ChainBlock GetBlockByNum(int) *model.ChainBlock SaveFillAlreadyBlockNum(context.Context, int) error SaveFillAlreadyFinalizedBlockNum(c context.Context, blockNum int) (err error) GetFillBestBlockNum(c context.Context) (num int, err error) GetBlockNumArr(start, end int) []int GetFillFinalizedBlockNum(c context.Context) (num int, err error) GetBlockList(page, row int) []model.ChainBlock BlockAsJson(c context.Context, block *model.ChainBlock) *model.ChainBlockJson CreateEvent(txn *GormDB, event *model.ChainEvent) error GetEventByBlockNum(blockNum int, where ...string) []model.ChainEventJson GetEventList(page, row int, order string, where ...string) ([]model.ChainEvent, int) GetEventsByIndex(extrinsicIndex string) []model.ChainEvent GetEventByIdx(index string) *model.ChainEvent CreateExtrinsic(c context.Context, txn *GormDB, extrinsic *model.ChainExtrinsic) error GetExtrinsicsByBlockNum(blockNum int) []model.ChainExtrinsicJson GetExtrinsicList(c context.Context, page, row int, order string, queryWhere ...string) ([]model.ChainExtrinsic, int) GetExtrinsicsByHash(c context.Context, hash string) *model.ChainExtrinsic GetExtrinsicsDetailByHash(c context.Context, hash string) *model.ExtrinsicDetail GetExtrinsicsDetailByIndex(c context.Context, index string) *model.ExtrinsicDetail ExtrinsicsAsJson(e *model.ChainExtrinsic) *model.ChainExtrinsicJson CreateLog(txn *GormDB, ce *model.ChainLog) error GetLogsByIndex(index string) *model.ChainLogJson GetLogByBlockNum(blockNum int) []model.ChainLogJson CreateEventDetail(txn *GormDB, eventDetail *EventDetail) error SetMetadata(c context.Context, metadata map[string]interface{}) (err error) IncrMetadata(c context.Context, filed string, incrNum int) (err error) GetMetadata(c context.Context) (ms map[string]string, err error) GetBestBlockNum(c context.Context) (uint64, error) GetFinalizedBlockNum(c context.Context) (uint64, error) CreateRuntimeVersion(name string, specVersion int) int64 SetRuntimeData(specVersion int, modules string, rawData string) int64 RuntimeVersionList() []model.RuntimeVersion RuntimeVersionRaw(spec int) *metadata.RuntimeRaw RuntimeVersionRecent() *model.RuntimeVersion SaveSpace(s *models.Space) error ListSapce() ([]models.Space, error) }
Click to show internal directories.
Click to hide internal directories.