model

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package model define archive db model

Index

Constants

View Source
const (
	// KArchivedblockheight archived_block_height
	KArchivedblockheight = "archived_block_height"
)

Variables

This section is empty.

Functions

func BlockInfoTableNameByBlockHeight

func BlockInfoTableNameByBlockHeight(blkHeight uint64) string

BlockInfoTableNameByBlockHeight Get BlockInfo table name by block height

func CreateBlockInfoTableIfNotExists

func CreateBlockInfoTableIfNotExists(db *gorm.DB, tableName string) error

CreateBlockInfoTableIfNotExists create table `tableName` if not exists

func DbName

func DbName(chainId string) string

DbName returns database name by chainId.

func GetArchivedBlockHeight

func GetArchivedBlockHeight(db *gorm.DB) (uint64, error)

GetArchivedBlockHeight get archived block height from db

func InitArchiveStatusData

func InitArchiveStatusData(db *gorm.DB) error

InitArchiveStatusData init archive status data @param db @return error

func InsertBlockInfo

func InsertBlockInfo(db *gorm.DB, chainId string, blkHeight uint64, blkWithRWSet []byte, hmac string) error

InsertBlockInfo insert block info into db

func RowsPerBlockInfoTable

func RowsPerBlockInfoTable() uint64

RowsPerBlockInfoTable returns rows per block info table

func UpdateArchivedBlockHeight

func UpdateArchivedBlockHeight(db *gorm.DB, archivedBlockHeight uint64) error

UpdateArchivedBlockHeight update archived block height in db

Types

type BaseModel

type BaseModel struct {
	ID        int64        `gorm:"primaryKey;column:Fid;type:int unsigned NOT NULL AUTO_INCREMENT"`
	CreatedAt sql.NullTime `gorm:"index;column:Fcreate_time;type:timestamp"`
	UpdatedAt sql.NullTime `gorm:"column:Fmodify_time;type:timestamp"`
	DeletedAt sql.NullTime `gorm:"column:Fdelete_time;type:timestamp"`
}

BaseModel define base db model

type BlockInfo

type BlockInfo struct {
	BaseModel
	ChainID        string `gorm:"column:Fchain_id;type:varchar(64) NOT NULL"`
	BlockHeight    uint64 `gorm:"column:Fblock_height;type:int unsigned NOT NULL;uniqueIndex:idx_blockheight"`
	BlockWithRWSet []byte `gorm:"column:Fblock_with_rwset;type:longblob NOT NULL"`
	Hmac           string `gorm:"column:Fhmac;type:varchar(64) NOT NULL"`
	IsArchived     bool   `gorm:"column:Fis_archived;type:tinyint(1) NOT NULL DEFAULT '0'"`
}

BlockInfo define block info db model

func (BlockInfo) TableName

func (BlockInfo) TableName() string

TableName The BlockInfo table name will be overwritten as 't_block_info_1' the first sharding table

type Sysinfo

type Sysinfo struct {
	BaseModel
	K string `gorm:"unique;type:varchar(64) NOT NULL"`
	V string `gorm:"type:varchar(8000) NOT NULL"`
}

Sysinfo define system info db model

Jump to

Keyboard shortcuts

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