datamanage

package
v0.0.0-...-48972bb Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCK_TABLE       = "block_t"
	TRANSACTION_TABLE = "transaction_t"
	ACTION_TABLE      = "action_t"
)
View Source
const ONCENUMS = 10

Variables

View Source
var (
	Block_Attr = []string{"height", "hash", "chain_id", "time", "num_txs",
		"last_commit_hash", "data_hash", "validators_hash", "app_hash"}
	Transaction_Attr = []string{"hash", "blkhash", "basefee", "txtype", "actions", "createtime"}
	Action_Attr      = []string{"actid", "txid", "txhash", "src", "dst", "amount", "body", "memo", "createtime"}
)

Functions

func CreateDB

func CreateDB() (err error)

func GetBlockData

func GetBlockData() (err error)

从chain获取从数据库height最大值起ONCENUMS的块数据,并分析tx,operation,数据插入数据库

func GetLastHeight

func GetLastHeight() (height uint64, err error)

获取数据库中height的最大值

func GetTypeString

func GetTypeString(itype int) string

func InitBlock

func InitBlock()

func InsertData

func InsertData(tableName string, fields []Field) (sql.Result, error)

func SelectRowsOffset

func SelectRowsOffset(table string, where []Where, order *Order, offset, limit uint64, result interface{}) error

Types

type Action

type Action struct {
	ID         uint64 `db:"id"`
	ActID      string `db:"actid"`
	TxID       uint64 `db:"txid"`
	TxHash     string `db:"txhash"`
	Src        string `db:"src"`
	Dst        string `db:"dst"`
	Amount     string `db:"amount"`
	Body       string `db:"body"`
	Memo       string `db:"memo"`
	CreateTime string `db:"createtime"`
}

func Getactions

func Getactions(txid uint64) (opts []Action, err error)

根据txid从数据库获取operations数据

type Block

type Block struct {
	Height        uint64 `db:"height"`
	Hash          string `db:"hash"`
	ChainID       string `db:"chain_id"`
	Time          string `db:"time"`
	NumTx         int    `db:"num_txs"`
	LastComitHash string `db:"last_commit_hash"`
	DataHash      string `db:"data_hash"`
	ValidHash     string `db:"validators_hash"`
	AppHash       string `db:"app_hash"`
}

func GetBlock

func GetBlock(num uint64) (blks []Block, err error)

获取指定num数量的block数据从数据库中

func GetBlockByHash

func GetBlockByHash(hash string) (blk Block, err error)

根据hash获取block

func GetBlockByHeight

func GetBlockByHeight(height uint64) (blk Block, err error)

根据height获取block

type Field

type Field struct {
	Name  string
	Value interface{}
}

func GeneratField

func GeneratField(names []string, args ...interface{}) (fields []Field)

type Order

type Order struct {
	Type   string   // "asc" or "desc"
	Feilds []string // order by x
}

Order used to identify query order

type Trans

type Trans struct {
	TxID       uint64 `db:"txid"`
	Hash       string `db:"hash"`
	BlockHash  string `db:"blkhash"`
	BaseFee    uint64 `db:"basefee"`
	TxType     uint8  `db:"txtype"`
	Actions    uint8  `db:"actions"`
	CreateTime uint64 `db:"createtime"`
}

func GetTxData

func GetTxData(hash string) (trans []Trans, err error)

从数据库中获取指定hash值得tx交易信息

type Where

type Where struct {
	Name  string
	Value interface{}
	Op    string // can be =、>、<、<> and any operator supported by sql-database
}

func (*Where) GetOp

func (w *Where) GetOp() string

GetOp get operator of current where clause, default =

Jump to

Keyboard shortcuts

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