database

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArgInvalid  = errors.New("invalid argument")
	ErrExist       = errors.New("item already exists")
	ErrNoEvents    = errors.New("the times of pop event is more than push")
	ErrNotExist    = errors.New("item does not exist")
	ErrRlpEncode   = errors.New("rlp encode err")
	ErrOutOfMemory = errors.New("out of memory")
	ErrUnKnown     = errors.New("")
)
View Source
var (
	ContextKeyCurrentBlock = "context.chain.current_block"
)

Functions

func CreateDB

func CreateDB(db *sql.DB) (sql.Result, error)

func Del

func Del(db *sql.DB, key string) error

func ErrIsNotExist

func ErrIsNotExist(err error) bool

func GetAddressKey

func GetAddressKey(addr common.Address) []byte

func GetBlockHashKey

func GetBlockHashKey(hash common.Hash) []byte

func GetCanonicalKey

func GetCanonicalKey(height uint32) []byte

func NewAccountData

func NewAccountData(address common.Address) *types.AccountData

func Open

func Open(driver string, dns string) (*sql.DB, error)

driver = "mysql" dns = root:123123@tcp(localhost:3306)/lemochain?charset=utf8mb4

Types

type AccountDao

type AccountDao struct {
	// contains filtered or unexported fields
}

func NewAccountDao

func NewAccountDao(db DBEngine) *AccountDao

func (*AccountDao) Get

func (dao *AccountDao) Get(addr common.Address) (*types.AccountData, error)

func (*AccountDao) GetDB

func (dao *AccountDao) GetDB() *sql.DB

func (*AccountDao) Set

func (dao *AccountDao) Set(addr common.Address, account *types.AccountData) error

type AssetDao

type AssetDao struct {
	// contains filtered or unexported fields
}

func NewAssetDao

func NewAssetDao(db DBEngine) *AssetDao

func (*AssetDao) Get

func (dao *AssetDao) Get(code common.Hash) (*types.Asset, error)

func (*AssetDao) GetPage

func (dao *AssetDao) GetPage(addr common.Address, start, limit int) ([]*types.Asset, error)

func (*AssetDao) GetPageWithTotal

func (dao *AssetDao) GetPageWithTotal(addr common.Address, start, limit int) ([]*types.Asset, int, error)

func (*AssetDao) Set

func (dao *AssetDao) Set(asset *types.Asset) error

type BlockDao

type BlockDao struct {
	// contains filtered or unexported fields
}

func NewBlockDao

func NewBlockDao(db DBEngine) *BlockDao

func (*BlockDao) GetBlock

func (dao *BlockDao) GetBlock(hash common.Hash) (*types.Block, error)

func (*BlockDao) GetBlockByHeight

func (dao *BlockDao) GetBlockByHeight(height uint32) (*types.Block, error)

func (*BlockDao) GetDB

func (dao *BlockDao) GetDB() *sql.DB

func (*BlockDao) IsExist

func (dao *BlockDao) IsExist(hash common.Hash) (bool, error)

func (*BlockDao) SetBlock

func (dao *BlockDao) SetBlock(hash common.Hash, block *types.Block) error

type CandidateDao

type CandidateDao struct {
	// contains filtered or unexported fields
}

func NewCandidateDao

func NewCandidateDao(engine DBEngine) *CandidateDao

func (*CandidateDao) Del

func (dao *CandidateDao) Del(user common.Address) error

func (*CandidateDao) GetPage

func (dao *CandidateDao) GetPage(start, limit int) ([]*CandidateItem, error)

func (*CandidateDao) GetPageWithTotal

func (dao *CandidateDao) GetPageWithTotal(start, limit int) ([]*CandidateItem, int, error)

func (*CandidateDao) GetTop

func (dao *CandidateDao) GetTop(size int) ([]*CandidateItem, error)

func (*CandidateDao) Set

func (dao *CandidateDao) Set(item *CandidateItem) error

type CandidateItem

type CandidateItem struct {
	User  common.Address
	Votes *big.Int
}

type Context

type Context struct {
	// contains filtered or unexported fields
}

type ContextDao

type ContextDao struct {
	// contains filtered or unexported fields
}

func NewContextDao

func NewContextDao(db DBEngine) *ContextDao

func (*ContextDao) ContextGet

func (dao *ContextDao) ContextGet(key string) ([]byte, error)

func (*ContextDao) ContextLoad

func (dao *ContextDao) ContextLoad() ([]*Context, error)

func (*ContextDao) ContextSet

func (dao *ContextDao) ContextSet(key string, val []byte) error

func (*ContextDao) GetCurrentBlock

func (dao *ContextDao) GetCurrentBlock() (*types.Block, error)

func (*ContextDao) SetCurrentBlock

func (dao *ContextDao) SetCurrentBlock(block *types.Block) error

type DBEngine

type DBEngine interface {
	GetDB() *sql.DB
}

type EquityDao

type EquityDao struct {
	// contains filtered or unexported fields
}

func NewEquityDao

func NewEquityDao(db DBEngine) *EquityDao

func (*EquityDao) Get

func (dao *EquityDao) Get(addr common.Address, id common.Hash) (*types.AssetEquity, error)

func (*EquityDao) GetPage

func (dao *EquityDao) GetPage(addr common.Address, start, limit int) ([]*types.AssetEquity, error)

func (*EquityDao) GetPageByCode

func (dao *EquityDao) GetPageByCode(addr common.Address, code common.Hash, start, limit int) ([]*types.AssetEquity, error)

func (*EquityDao) GetPageByCodeWithTotal

func (dao *EquityDao) GetPageByCodeWithTotal(addr common.Address, code common.Hash, start, limit int) ([]*types.AssetEquity, int, error)

func (*EquityDao) GetPageWithTotal

func (dao *EquityDao) GetPageWithTotal(addr common.Address, start, limit int) ([]*types.AssetEquity, int, error)

func (*EquityDao) Set

func (dao *EquityDao) Set(addr common.Address, assetEquity *types.AssetEquity) error

type KvDao

type KvDao struct {
	// contains filtered or unexported fields
}

*

  • (1) hash => block
  • (2) hash => tx
  • (3) address => account

func NewKvDao

func NewKvDao(db DBEngine) *KvDao

func (*KvDao) Get

func (dao *KvDao) Get(key []byte) ([]byte, error)

func (*KvDao) Set

func (dao *KvDao) Set(key []byte, val []byte) error

type MateData

type MateData struct {
	Id      common.Hash    `json:"id" gencodec:"required"`
	Code    common.Hash    `json:"code" gencodec:"required"`
	Owner   common.Address `json:"owner" gencodec:"required"`
	Profile string         `json:"profile" gencodec:"required"`
}

type MateDataDao

type MateDataDao struct {
	// contains filtered or unexported fields
}

func NewMateDataDao

func NewMateDataDao(db DBEngine) *MateDataDao

func (*MateDataDao) Get

func (dao *MateDataDao) Get(id common.Hash) (*MateData, error)

func (*MateDataDao) GetPage

func (dao *MateDataDao) GetPage(addr common.Address, start, limit int) ([]*MateData, error)

func (*MateDataDao) GetPageByCode

func (dao *MateDataDao) GetPageByCode(code common.Hash, start, limit int) ([]*MateData, error)

func (*MateDataDao) GetPageByCodeWithTotal

func (dao *MateDataDao) GetPageByCodeWithTotal(code common.Hash, start, limit int) ([]*MateData, int, error)

func (*MateDataDao) GetPageWithTotal

func (dao *MateDataDao) GetPageWithTotal(addr common.Address, start, limit int) ([]*MateData, int, error)

func (*MateDataDao) Set

func (dao *MateDataDao) Set(mateData *MateData) error

type MySqlDB

type MySqlDB struct {
	// contains filtered or unexported fields
}

func NewMySqlDB

func NewMySqlDB(driver string, dns string) *MySqlDB

func (*MySqlDB) Clear

func (db *MySqlDB) Clear() error

func (*MySqlDB) Close

func (db *MySqlDB) Close()

func (*MySqlDB) GetDB

func (db *MySqlDB) GetDB() *sql.DB

type Tx

type Tx struct {
	BHash  common.Hash
	Height uint32
	THash  common.Hash
	From   common.Address
	To     common.Address
	Tx     *types.Transaction
	St     int64
}

type TxDao

type TxDao struct {
	// contains filtered or unexported fields
}

func NewTxDao

func NewTxDao(db DBEngine) *TxDao

func (*TxDao) Get

func (dao *TxDao) Get(hash common.Hash) (*Tx, error)

func (*TxDao) GetByAddr

func (dao *TxDao) GetByAddr(addr common.Address, start, limit int) ([]*Tx, error)

func (*TxDao) GetByAddrWithTotal

func (dao *TxDao) GetByAddrWithTotal(addr common.Address, start, limit int) ([]*Tx, int, error)

func (*TxDao) GetByFrom

func (dao *TxDao) GetByFrom(addr common.Address, start, limit int) ([]*Tx, error)

func (*TxDao) GetByFromWithTotal

func (dao *TxDao) GetByFromWithTotal(addr common.Address, start, limit int) ([]*Tx, int, error)

func (*TxDao) GetByTime

func (dao *TxDao) GetByTime(addr common.Address, stStart, stStop int64, start, limit int) ([]*Tx, error)

func (*TxDao) GetByTimeWithTotal

func (dao *TxDao) GetByTimeWithTotal(addr common.Address, stStart, stStop int64, start, limit int) ([]*Tx, int, error)

func (*TxDao) GetByTo

func (dao *TxDao) GetByTo(addr common.Address, start, limit int) ([]*Tx, error)

func (*TxDao) GetByToWithTotal

func (dao *TxDao) GetByToWithTotal(addr common.Address, start, limit int) ([]*Tx, int, error)

func (*TxDao) Set

func (dao *TxDao) Set(tx *Tx) error

Jump to

Keyboard shortcuts

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