Documentation
¶
Index ¶
- Constants
- Variables
- func Byte2Uint32(val []byte) uint32
- func CheckSum(data []byte) uint16
- func ClearData()
- func CreateBlock(hash common.Hash, parent common.Hash, height uint32) *types.Block
- func CreateBufWithNumber(size int) ([]byte, error)
- func CreateBufWithNumberBatch(cnt int, template []byte) ([][]byte, error)
- func CreateDB(db *sql.DB) (sql.Result, error)
- func CreateFile(path string) error
- func CreateSign(cnt int) ([]types.SignData, error)
- func Del(db *sql.DB, key string) error
- func Get(db *sql.DB, key string) ([]byte, error)
- func GetAccount(address string, balance int64, version uint32) *types.AccountData
- func GetAccounts() []*types.AccountData
- func GetBlock0() *types.Block
- func GetBlock1() *types.Block
- func GetBlock2() *types.Block
- func GetBlock3() *types.Block
- func GetBlock4() *types.Block
- func GetBucketIndex(pos uint32) uint32
- func GetItemIndex(pos uint32) uint32
- func GetPos(bucketIndex uint32, itemIndex uint32) uint32
- func GetRandomString(len int) string
- func GetStorePath() string
- func InitTable(db *sql.DB)
- func IsExist(path string) (bool, error)
- func NewBlockBatch(size int) []*types.Block
- func NewKey1() ([]byte, uint32)
- func NewKey2() ([]byte, uint32)
- func NewKey3() ([]byte, uint32)
- func Open(driver string, dns string) (*sql.DB, error)
- func Set(db *sql.DB, key string, val []byte) error
- func TxGet8AddrNext(db *sql.DB, addr string, start int64, size int) ([][]byte, []int64, int64, error)
- func TxGet8AddrPre(db *sql.DB, addr string, start int64, size int) ([][]byte, []int64, int64, error)
- func TxGet8Hash(db *sql.DB, hash string) ([]byte, int64, error)
- func TxSet(db *sql.DB, hash, from, to string, val []byte, ver int64, st int64) error
- type AccountTrieDB
- func (db *AccountTrieDB) Clone() *AccountTrieDB
- func (db *AccountTrieDB) Collect(dye uint32) []*types.AccountData
- func (db *AccountTrieDB) Get(address common.Address) (*types.AccountData, error)
- func (db *AccountTrieDB) GetReader() DatabaseReader
- func (db *AccountTrieDB) GetTrie() *PatriciaTrie
- func (db *AccountTrieDB) Put(account *types.AccountData, dye uint32)
- func (db *AccountTrieDB) Set(account *types.AccountData)
- func (db *AccountTrieDB) SetReader(reader DatabaseReader)
- func (db *AccountTrieDB) SetTrie(trie *PatriciaTrie)
- type AfterScan
- type Batch
- type BatchItem
- type BeansDB
- func (beansdb *BeansDB) AfterScan(flag uint, route []byte, key []byte, val []byte, offset uint32) error
- func (beansdb *BeansDB) Close() error
- func (beansdb *BeansDB) Commit(batch Batch) error
- func (beansdb *BeansDB) Get(key []byte) ([]byte, error)
- func (beansdb *BeansDB) Has(key []byte) (bool, error)
- func (beansdb *BeansDB) NewBatch(route []byte) Batch
- func (beansdb *BeansDB) Put(flg uint, route []byte, key []byte, val []byte) error
- type BitCask
- func (bitcask *BitCask) Close() error
- func (bitcask *BitCask) Commit(batch Batch) error
- func (bitcask *BitCask) Delete(flag int, route []byte, key []byte) error
- func (bitcask *BitCask) Get(flag uint, route []byte, key []byte, offset int64) ([]byte, error)
- func (bitcask *BitCask) Get4Cache(route []byte, key []byte) ([]byte, error)
- func (bitcask *BitCask) NewBatch(route []byte) Batch
- func (bitcask *BitCask) Put(flag uint, route []byte, key []byte, val []byte) error
- type BitcaskIndexes
- type BizAfterScan
- type BizDatabase
- type BizDb
- type CBlock
- type CachedNode
- type Candidate
- type CandidateCache
- func (cache *CandidateCache) Decode(buf []byte, length int) error
- func (cache *CandidateCache) Encode() ([]byte, int)
- func (cache *CandidateCache) GetCandidatePage(index int, size int) ([]common.Address, uint32, error)
- func (cache *CandidateCache) GetCandidates() ([]*Candidate, error)
- func (cache *CandidateCache) IsExist(address common.Address) bool
- func (cache *CandidateCache) Set(candidate *Candidate) error
- type CandidatePos
- type CandidateTrieDB
- func (db *CandidateTrieDB) Clone() *CandidateTrieDB
- func (db *CandidateTrieDB) Get(address common.Address) (*Candidate, error)
- func (db *CandidateTrieDB) GetAll() []*Candidate
- func (db *CandidateTrieDB) GetReader() DatabaseReader
- func (db *CandidateTrieDB) GetTrie() *PatriciaTrie
- func (db *CandidateTrieDB) Put(candidate *Candidate, dye uint32)
- func (db *CandidateTrieDB) Set(candidate *Candidate)
- func (db *CandidateTrieDB) SetReader(reader DatabaseReader)
- func (db *CandidateTrieDB) SetTrie(trie *PatriciaTrie)
- type ChainDatabase
- func (database *ChainDatabase) AfterScan(flag uint, key []byte, val []byte) error
- func (database *ChainDatabase) CandidatesRanking(hash common.Hash)
- func (database *ChainDatabase) Close() error
- func (database *ChainDatabase) GetAccount(addr common.Address) (*types.AccountData, error)
- func (database *ChainDatabase) GetActDatabase(hash common.Hash) (*AccountTrieDB, error)
- func (database *ChainDatabase) GetBizDatabase() BizDb
- func (database *ChainDatabase) GetBlock(hash common.Hash, height uint32) (*types.Block, error)
- func (database *ChainDatabase) GetBlockByHash(hash common.Hash) (*types.Block, error)
- func (database *ChainDatabase) GetBlockByHeight(height uint32) (*types.Block, error)
- func (database *ChainDatabase) GetCandidatesPage(index int, size int) ([]common.Address, uint32, error)
- func (database *ChainDatabase) GetCandidatesTop(hash common.Hash) []*Candidate
- func (database *ChainDatabase) GetConfirms(hash common.Hash) ([]types.SignData, error)
- func (database *ChainDatabase) GetContractCode(hash common.Hash) (types.Code, error)
- func (database *ChainDatabase) GetLastConfirm() *CBlock
- func (database *ChainDatabase) GetTrieDatabase() *TrieDatabase
- func (database *ChainDatabase) IsExistByHash(hash common.Hash) (bool, error)
- func (database *ChainDatabase) LoadLatestBlock() (*types.Block, error)
- func (database *ChainDatabase) SetBlock(hash common.Hash, block *types.Block) error
- func (database *ChainDatabase) SetConfirm(hash common.Hash, signData types.SignData) error
- func (database *ChainDatabase) SetConfirms(hash common.Hash, pack []types.SignData) error
- func (database *ChainDatabase) SetContractCode(hash common.Hash, code types.Code) error
- func (database *ChainDatabase) SetStableBlock(hash common.Hash) error
- func (database *ChainDatabase) SizeOfValue(hash common.Hash) (int, error)
- type Commit
- type DB
- type DBReader
- type DBWriter
- type Database
- type DatabaseReader
- type Index
- type IndexReader
- type LDBDatabase
- func (db *LDBDatabase) Close()
- func (db *LDBDatabase) Commit(batch Batch) error
- func (db *LDBDatabase) Delete(key []byte) error
- func (db *LDBDatabase) Get(key []byte) ([]byte, error)
- func (db *LDBDatabase) Has(key []byte) (bool, error)
- func (db *LDBDatabase) NewBatch(route []byte) Batch
- func (db *LDBDatabase) Put(key []byte, value []byte) error
- type LastIndex
- type LmBuffer
- type LmDBBatch
- type MemDatabase
- func (db *MemDatabase) Close()
- func (db *MemDatabase) Delete(key []byte) error
- func (db *MemDatabase) Get(key []byte) ([]byte, error)
- func (db *MemDatabase) Has(key []byte) (bool, error)
- func (db *MemDatabase) Keys() [][]byte
- func (db *MemDatabase) Len() int
- func (db *MemDatabase) NewBatch(route []byte) Batch
- func (db *MemDatabase) Put(key []byte, value []byte) error
- type MySqlDB
- func (db *MySqlDB) Clear() error
- func (db *MySqlDB) Close()
- func (db *MySqlDB) GetIndex(key []byte) (int, []byte, int64, error)
- func (db *MySqlDB) SetIndex(flg int, route []byte, key []byte, offset int64) error
- func (db *MySqlDB) TxGetByAddr(addr string, index int, size int) ([]string, [][]byte, []int64, error)
- func (db *MySqlDB) TxGetByHash(key string) (string, []byte, int64, error)
- func (db *MySqlDB) TxSet(hash, blockHash, from, to string, val []byte, ver int64, st int64) error
- type NewBatch
- type PatriciaNode
- type PatriciaTrie
- func (trie *PatriciaTrie) All() []types.NodeData
- func (trie *PatriciaTrie) Clone() *PatriciaTrie
- func (trie *PatriciaTrie) Collected(dye uint32) []types.NodeData
- func (trie *PatriciaTrie) DelDye(dye uint32)
- func (trie *PatriciaTrie) Find(key string) types.NodeData
- func (trie *PatriciaTrie) Insert(key string, data types.NodeData) error
- func (trie *PatriciaTrie) Put(key string, data types.NodeData, dye uint32)
- type RBody
- type RHead
- type RIndex
- type Reader
- type RunContext
- func (context *RunContext) CandidateIsExist(address common.Address) bool
- func (context *RunContext) Flush() error
- func (context *RunContext) GetCandidatePage(index int, size int) ([]common.Address, uint32, error)
- func (context *RunContext) GetCandidates() ([]*Candidate, error)
- func (context *RunContext) GetStableBlock() *types.Block
- func (context *RunContext) Load() error
- func (context *RunContext) SetCandidate(candidate *Candidate) error
- func (context *RunContext) SetCandidates(candidates []*Candidate) error
- func (context *RunContext) SetStableBlock(block *types.Block)
- type TrieDatabase
- func (db *TrieDatabase) Commit(node common.Hash, report bool) error
- func (db *TrieDatabase) Dereference(child common.Hash, parent common.Hash)
- func (db *TrieDatabase) DiskDB() DatabaseReader
- func (db *TrieDatabase) DiskDB4Test() Database
- func (db *TrieDatabase) Insert(hash common.Hash, blob []byte)
- func (db *TrieDatabase) InsertPreimage(hash common.Hash, preimage []byte)
- func (db *TrieDatabase) Lock()
- func (db *TrieDatabase) Node(hash common.Hash) ([]byte, error)
- func (db *TrieDatabase) Nodes() []common.Hash
- func (db *TrieDatabase) Nodes4Test() map[common.Hash]*CachedNode
- func (db *TrieDatabase) Preimage(hash common.Hash) ([]byte, error)
- func (db *TrieDatabase) Reference(child common.Hash, parent common.Hash)
- func (db *TrieDatabase) Size() common.StorageSize
- func (db *TrieDatabase) UnLock()
- type VTransaction
- type VTransactionDetail
- type VoteTop
- func (top *VoteTop) Clear()
- func (top *VoteTop) Clone() *VoteTop
- func (top *VoteTop) Count() int
- func (top *VoteTop) GetTop() []*Candidate
- func (top *VoteTop) Max() *Candidate
- func (top *VoteTop) Min() *Candidate
- func (top *VoteTop) Rank(topSize int, candidates []*Candidate)
- func (top *VoteTop) Reset(candidates []*Candidate)
Constants ¶
const IdealBatchSize = 100 * 1024
Code using batches should try to add this much data to the batch. The value was determined empirically.
Variables ¶
var ( CACHE_FLG_STOP = uint(0) CACHE_FLG_BLOCK = uint(1) CACHE_FLG_BLOCK_HEIGHT = uint(2) CACHE_FLG_TRIE = uint(3) CACHE_FLG_ACT = uint(4) CACHE_FLG_TX_INDEX = uint(5) CACHE_FLG_CODE = uint(6) CACHE_FLG_KV = uint(7) )
var ( DRIVER_MYSQL = "mysql" DNS_MYSQL = "root:123456@tcp(localhost:3306)/lemochain?charset=utf8mb4" )
var ( ErrArgInvalid = errors.New("invalid argument") ErrExist = errors.New("item already exists") ErrNotExist = errors.New("item does not exist") ErrAncestorsNotExist = errors.New("the block's ancestors does not exist") ErrEOF = errors.New("file EOF") ErrRlpEncode = errors.New("rlp encode err") ErrOutOfMemory = errors.New("out of memory") ErrUnKnown = errors.New("") )
var MbTable = []uint16{}/* 256 elements not displayed */
var OpenFileLimit = 64
var RHEAD_LENGTH = binary.Size(RHead{})
Functions ¶
func Byte2Uint32 ¶
func CreateBlock ¶
func CreateBufWithNumber ¶
func CreateFile ¶ added in v1.1.0
func GetAccount ¶
func GetAccount(address string, balance int64, version uint32) *types.AccountData
func GetAccounts ¶
func GetAccounts() []*types.AccountData
func GetBucketIndex ¶
func GetItemIndex ¶
func GetRandomString ¶ added in v1.1.0
func GetStorePath ¶
func GetStorePath() string
func NewBlockBatch ¶ added in v1.1.0
func Open ¶ added in v1.1.0
driver = "mysql" dns = root:123123@tcp(localhost:3306)/lemochain?charset=utf8mb4
func TxGet8AddrNext ¶ added in v1.1.0
func TxGet8AddrPre ¶ added in v1.1.0
Types ¶
type AccountTrieDB ¶ added in v1.1.1
type AccountTrieDB struct {
// contains filtered or unexported fields
}
AccountAPI
func NewAccountTrieDB ¶ added in v1.1.1
func NewAccountTrieDB(trie *PatriciaTrie, reader DatabaseReader) *AccountTrieDB
func NewEmptyAccountTrieDB ¶ added in v1.1.1
func NewEmptyAccountTrieDB(reader DatabaseReader) *AccountTrieDB
func (*AccountTrieDB) Clone ¶ added in v1.1.1
func (db *AccountTrieDB) Clone() *AccountTrieDB
func (*AccountTrieDB) Collect ¶ added in v1.1.1
func (db *AccountTrieDB) Collect(dye uint32) []*types.AccountData
func (*AccountTrieDB) Get ¶ added in v1.1.1
func (db *AccountTrieDB) Get(address common.Address) (*types.AccountData, error)
func (*AccountTrieDB) GetReader ¶ added in v1.1.1
func (db *AccountTrieDB) GetReader() DatabaseReader
func (*AccountTrieDB) GetTrie ¶ added in v1.1.1
func (db *AccountTrieDB) GetTrie() *PatriciaTrie
func (*AccountTrieDB) Put ¶ added in v1.1.1
func (db *AccountTrieDB) Put(account *types.AccountData, dye uint32)
func (*AccountTrieDB) Set ¶ added in v1.1.1
func (db *AccountTrieDB) Set(account *types.AccountData)
func (*AccountTrieDB) SetReader ¶ added in v1.1.1
func (db *AccountTrieDB) SetReader(reader DatabaseReader)
func (*AccountTrieDB) SetTrie ¶ added in v1.1.1
func (db *AccountTrieDB) SetTrie(trie *PatriciaTrie)
type Batch ¶
type Batch interface {
Put(flg uint, key, value []byte) error
Commit() error
Route() []byte
Items() []*BatchItem
ValueSize() int
Reset()
}
Batch is a write-only database that commits changes to its host database when Write is called. Batch cannot be used concurrently.
type BeansDB ¶ added in v1.1.0
type BeansDB struct {
// contains filtered or unexported fields
}
func NewBeansDB ¶ added in v1.1.0
func NewBeansDB(home string, height int, DB *MySqlDB, after BizAfterScan) *BeansDB
type BitCask ¶ added in v1.1.0
type BitCask struct {
HomePath string
CurIndex int
CurOffset int64
Cache map[string]RIndex
After AfterScan
IndexDB DB
// contains filtered or unexported fields
}
func NewBitCask ¶ added in v1.1.0
type BitcaskIndexes ¶ added in v1.1.0
type BitcaskIndexes [256]LastIndex
type BizDatabase ¶ added in v1.1.0
func NewBizDatabase ¶ added in v1.1.0
func NewBizDatabase(reader Reader, database *MySqlDB) *BizDatabase
func (*BizDatabase) AfterCommit ¶ added in v1.1.0
func (db *BizDatabase) AfterCommit(flag uint, key []byte, val []byte) error
func (*BizDatabase) GetTxByAddr ¶ added in v1.1.0
func (db *BizDatabase) GetTxByAddr(src common.Address, index int, size int) ([]*VTransaction, uint32, error)
func (*BizDatabase) GetTxByHash ¶ added in v1.1.0
func (db *BizDatabase) GetTxByHash(hash common.Hash) (*VTransactionDetail, error)
type CBlock ¶ added in v1.1.0
type CBlock struct {
Block *types.Block
AccountTrieDB *AccountTrieDB
CandidateTrieDB *CandidateTrieDB
Top *VoteTop
}
func NewGenesisBlock ¶ added in v1.1.1
func NewGenesisBlock(block *types.Block, reader DatabaseReader) *CBlock
func NewNormalBlock ¶ added in v1.1.1
func NewNormalBlock(block *types.Block, accountTrieDB *AccountTrieDB, candidateTrieDB *CandidateTrieDB, top *VoteTop) *CBlock
type CachedNode ¶
type CachedNode struct {
Blob []byte // Cached data block of the trie node
Parents int // Number of live nodes referencing this one
Children map[common.Hash]int // Children referenced by this nodes
}
CachedNode is all the information we know about a single cached node in the memory database write layer.
type Candidate ¶ added in v1.1.0
func (*Candidate) GetAddress ¶ added in v1.1.0
type CandidateCache ¶ added in v1.1.1
type CandidateCache struct {
Candidates map[common.Address]CandidatePos
ItemMaxSize int
Cap int
Cur int
CandidateBuf []byte
}
func NewCandidateCache ¶ added in v1.1.1
func NewCandidateCache() *CandidateCache
func (*CandidateCache) Decode ¶ added in v1.1.1
func (cache *CandidateCache) Decode(buf []byte, length int) error
func (*CandidateCache) Encode ¶ added in v1.1.1
func (cache *CandidateCache) Encode() ([]byte, int)
func (*CandidateCache) GetCandidatePage ¶ added in v1.1.1
func (*CandidateCache) GetCandidates ¶ added in v1.1.1
func (cache *CandidateCache) GetCandidates() ([]*Candidate, error)
func (*CandidateCache) IsExist ¶ added in v1.1.1
func (cache *CandidateCache) IsExist(address common.Address) bool
func (*CandidateCache) Set ¶ added in v1.1.1
func (cache *CandidateCache) Set(candidate *Candidate) error
type CandidatePos ¶ added in v1.1.1
type CandidateTrieDB ¶ added in v1.1.1
type CandidateTrieDB struct {
// contains filtered or unexported fields
}
CandidateAPI
func NewEmptyCandidateTrieDB ¶ added in v1.1.1
func NewEmptyCandidateTrieDB() *CandidateTrieDB
func (*CandidateTrieDB) Clone ¶ added in v1.1.1
func (db *CandidateTrieDB) Clone() *CandidateTrieDB
func (*CandidateTrieDB) Get ¶ added in v1.1.1
func (db *CandidateTrieDB) Get(address common.Address) (*Candidate, error)
func (*CandidateTrieDB) GetAll ¶ added in v1.1.1
func (db *CandidateTrieDB) GetAll() []*Candidate
func (*CandidateTrieDB) GetReader ¶ added in v1.1.1
func (db *CandidateTrieDB) GetReader() DatabaseReader
func (*CandidateTrieDB) GetTrie ¶ added in v1.1.1
func (db *CandidateTrieDB) GetTrie() *PatriciaTrie
func (*CandidateTrieDB) Put ¶ added in v1.1.1
func (db *CandidateTrieDB) Put(candidate *Candidate, dye uint32)
func (*CandidateTrieDB) Set ¶ added in v1.1.1
func (db *CandidateTrieDB) Set(candidate *Candidate)
func (*CandidateTrieDB) SetReader ¶ added in v1.1.1
func (db *CandidateTrieDB) SetReader(reader DatabaseReader)
func (*CandidateTrieDB) SetTrie ¶ added in v1.1.1
func (db *CandidateTrieDB) SetTrie(trie *PatriciaTrie)
type ChainDatabase ¶ added in v1.1.0
type ChainDatabase struct {
LastConfirm *CBlock
UnConfirmBlocks map[common.Hash]*CBlock
Context *RunContext
DB *MySqlDB
Beansdb *BeansDB
BizDB *BizDatabase
// contains filtered or unexported fields
}
func NewChainDataBase ¶ added in v1.1.0
func NewChainDataBase(home string, driver string, dns string) *ChainDatabase
func (*ChainDatabase) AfterScan ¶ added in v1.1.0
func (database *ChainDatabase) AfterScan(flag uint, key []byte, val []byte) error
func (*ChainDatabase) CandidatesRanking ¶ added in v1.1.0
func (database *ChainDatabase) CandidatesRanking(hash common.Hash)
func (*ChainDatabase) Close ¶ added in v1.1.0
func (database *ChainDatabase) Close() error
func (*ChainDatabase) GetAccount ¶ added in v1.1.0
func (database *ChainDatabase) GetAccount(addr common.Address) (*types.AccountData, error)
GetAccount loads account from cache or db
func (*ChainDatabase) GetActDatabase ¶ added in v1.1.0
func (database *ChainDatabase) GetActDatabase(hash common.Hash) (*AccountTrieDB, error)
func (*ChainDatabase) GetBizDatabase ¶ added in v1.1.0
func (database *ChainDatabase) GetBizDatabase() BizDb
func (*ChainDatabase) GetBlockByHash ¶ added in v1.1.0
func (*ChainDatabase) GetBlockByHeight ¶ added in v1.1.0
func (database *ChainDatabase) GetBlockByHeight(height uint32) (*types.Block, error)
func (*ChainDatabase) GetCandidatesPage ¶ added in v1.1.0
func (*ChainDatabase) GetCandidatesTop ¶ added in v1.1.0
func (database *ChainDatabase) GetCandidatesTop(hash common.Hash) []*Candidate
func (*ChainDatabase) GetConfirms ¶ added in v1.1.0
func (*ChainDatabase) GetContractCode ¶ added in v1.1.0
GetContractCode loads contract's code from db.
func (*ChainDatabase) GetLastConfirm ¶ added in v1.1.0
func (database *ChainDatabase) GetLastConfirm() *CBlock
func (*ChainDatabase) GetTrieDatabase ¶ added in v1.1.0
func (database *ChainDatabase) GetTrieDatabase() *TrieDatabase
func (*ChainDatabase) IsExistByHash ¶ added in v1.1.0
func (database *ChainDatabase) IsExistByHash(hash common.Hash) (bool, error)
func (*ChainDatabase) LoadLatestBlock ¶ added in v1.1.0
func (database *ChainDatabase) LoadLatestBlock() (*types.Block, error)
func (*ChainDatabase) SetConfirm ¶ added in v1.1.0
设置区块的确认信息 每次收到一个
func (*ChainDatabase) SetConfirms ¶ added in v1.1.0
func (*ChainDatabase) SetContractCode ¶ added in v1.1.0
SetContractCode saves contract's code
func (*ChainDatabase) SetStableBlock ¶ added in v1.1.0
func (database *ChainDatabase) SetStableBlock(hash common.Hash) error
func (*ChainDatabase) SizeOfValue ¶ added in v1.1.0
func (database *ChainDatabase) SizeOfValue(hash common.Hash) (int, error)
type Database ¶
type Database interface {
Put(key, value []byte) error
NewBatch
Get(key []byte) ([]byte, error)
Has(key []byte) (bool, error)
Delete(key []byte) error
Close()
}
Database wraps all database operations. All methods are safe for concurrent use.
type DatabaseReader ¶
type DatabaseReader interface {
// Get retrieves the value associated with key form the database.
Get(key []byte) (value []byte, err error)
// Has retrieves whether a key is present in the database.
Has(key []byte) (bool, error)
}
DatabaseReader wraps the Get and Has method of a backing store for the trie.
type IndexReader ¶ added in v1.1.0
type IndexReader interface {
Get(key []byte)
}
type LDBDatabase ¶
type LDBDatabase struct {
// contains filtered or unexported fields
}
func NewLDBDatabase ¶
func NewLDBDatabase(beansdb *BeansDB) *LDBDatabase
NewLDBDatabase returns a LevelDB wrapped object.
func (*LDBDatabase) Close ¶
func (db *LDBDatabase) Close()
func (*LDBDatabase) Commit ¶ added in v1.1.0
func (db *LDBDatabase) Commit(batch Batch) error
func (*LDBDatabase) Delete ¶
func (db *LDBDatabase) Delete(key []byte) error
Delete deletes the key from the queue and database
func (*LDBDatabase) Get ¶
func (db *LDBDatabase) Get(key []byte) ([]byte, error)
Get returns the given key if it's present.
func (*LDBDatabase) NewBatch ¶
func (db *LDBDatabase) NewBatch(route []byte) Batch
type LmBuffer ¶
type LmBuffer struct {
// contains filtered or unexported fields
}
func NewLmBuffer ¶
type LmDBBatch ¶ added in v1.1.0
type LmDBBatch struct {
// contains filtered or unexported fields
}
type MemDatabase ¶
type MemDatabase struct {
// contains filtered or unexported fields
}
* This is a test memory database. Do not use for any production it does not get persisted
func NewMemDatabase ¶
func NewMemDatabase() (*MemDatabase, error)
func NewMemDatabaseWithCap ¶
func NewMemDatabaseWithCap(size int) (*MemDatabase, error)
func (*MemDatabase) Close ¶
func (db *MemDatabase) Close()
func (*MemDatabase) Delete ¶
func (db *MemDatabase) Delete(key []byte) error
func (*MemDatabase) Keys ¶
func (db *MemDatabase) Keys() [][]byte
func (*MemDatabase) Len ¶
func (db *MemDatabase) Len() int
func (*MemDatabase) NewBatch ¶
func (db *MemDatabase) NewBatch(route []byte) Batch
type MySqlDB ¶ added in v1.1.0
type MySqlDB struct {
// contains filtered or unexported fields
}
func NewMySqlDB ¶ added in v1.1.0
func (*MySqlDB) TxGetByAddr ¶ added in v1.1.0
func (*MySqlDB) TxGetByHash ¶ added in v1.1.0
type PatriciaNode ¶ added in v1.1.0
type PatriciaNode struct {
// contains filtered or unexported fields
}
func (*PatriciaNode) Clone ¶ added in v1.1.0
func (node *PatriciaNode) Clone() *PatriciaNode
type PatriciaTrie ¶ added in v1.1.0
type PatriciaTrie struct {
// contains filtered or unexported fields
}
func NewActDatabase ¶ added in v1.1.0
func NewActDatabase(root *PatriciaTrie) *PatriciaTrie
func NewEmptyDatabase ¶ added in v1.1.0
func NewEmptyDatabase() *PatriciaTrie
func (*PatriciaTrie) All ¶ added in v1.1.1
func (trie *PatriciaTrie) All() []types.NodeData
func (*PatriciaTrie) Clone ¶ added in v1.1.0
func (trie *PatriciaTrie) Clone() *PatriciaTrie
func (*PatriciaTrie) Collected ¶ added in v1.1.0
func (trie *PatriciaTrie) Collected(dye uint32) []types.NodeData
func (*PatriciaTrie) DelDye ¶ added in v1.1.0
func (trie *PatriciaTrie) DelDye(dye uint32)
func (*PatriciaTrie) Find ¶ added in v1.1.0
func (trie *PatriciaTrie) Find(key string) types.NodeData
type RunContext ¶ added in v1.1.0
type RunContext struct {
Path string
StableBlock *types.Block
Candidates *CandidateCache
}
func NewRunContext ¶ added in v1.1.0
func NewRunContext(path string) *RunContext
func (*RunContext) CandidateIsExist ¶ added in v1.1.0
func (context *RunContext) CandidateIsExist(address common.Address) bool
func (*RunContext) Flush ¶ added in v1.1.0
func (context *RunContext) Flush() error
func (*RunContext) GetCandidatePage ¶ added in v1.1.0
func (*RunContext) GetCandidates ¶ added in v1.1.1
func (context *RunContext) GetCandidates() ([]*Candidate, error)
func (*RunContext) GetStableBlock ¶ added in v1.1.0
func (context *RunContext) GetStableBlock() *types.Block
func (*RunContext) Load ¶ added in v1.1.0
func (context *RunContext) Load() error
func (*RunContext) SetCandidate ¶ added in v1.1.0
func (context *RunContext) SetCandidate(candidate *Candidate) error
func (*RunContext) SetCandidates ¶ added in v1.1.1
func (context *RunContext) SetCandidates(candidates []*Candidate) error
func (*RunContext) SetStableBlock ¶ added in v1.1.0
func (context *RunContext) SetStableBlock(block *types.Block)
type TrieDatabase ¶
type TrieDatabase struct {
// contains filtered or unexported fields
}
Database is an intermediate write layer between the trie data structures and the disk database. The aim is to accumulate trie writes in-memory and only periodically flush a couple tries to disk, garbage collecting the remainder.
func NewTrieDatabase ¶
func NewTrieDatabase(diskdb Database) *TrieDatabase
NewTrieDatabase creates a new trie database to store ephemeral trie content before its written out to disk or garbage collected.
func (*TrieDatabase) Commit ¶
func (db *TrieDatabase) Commit(node common.Hash, report bool) error
Commit iterates over all the Children of a particular node, writes them out to disk, forcefully tearing down all references in both directions.
As a side effect, all pre-images accumulated up to this point are also written.
func (*TrieDatabase) Dereference ¶
func (db *TrieDatabase) Dereference(child common.Hash, parent common.Hash)
Dereference removes an existing reference from a parent node to a child node.
func (*TrieDatabase) DiskDB ¶
func (db *TrieDatabase) DiskDB() DatabaseReader
DiskDB retrieves the persistent storage backing the trie database.
func (*TrieDatabase) DiskDB4Test ¶
func (db *TrieDatabase) DiskDB4Test() Database
func (*TrieDatabase) Insert ¶
func (db *TrieDatabase) Insert(hash common.Hash, blob []byte)
Insert writes a new trie node to the memory database if it's yet unknown. The method will make a copy of the slice.
func (*TrieDatabase) InsertPreimage ¶
func (db *TrieDatabase) InsertPreimage(hash common.Hash, preimage []byte)
insertPreimage writes a new trie node pre-image to the memory database if it's yet unknown. The method will make a copy of the slice.
Note, this method assumes that the database's lock is held!
func (*TrieDatabase) Lock ¶
func (db *TrieDatabase) Lock()
func (*TrieDatabase) Node ¶
func (db *TrieDatabase) Node(hash common.Hash) ([]byte, error)
Node retrieves a cached trie node from memory. If it cannot be found cached, the method queries the persistent database for the content.
func (*TrieDatabase) Nodes ¶
func (db *TrieDatabase) Nodes() []common.Hash
Nodes retrieves the hashes of all the nodes cached within the memory database. This method is extremely expensive and should only be used to validate internal states in test code.
func (*TrieDatabase) Nodes4Test ¶
func (db *TrieDatabase) Nodes4Test() map[common.Hash]*CachedNode
func (*TrieDatabase) Preimage ¶
func (db *TrieDatabase) Preimage(hash common.Hash) ([]byte, error)
preimage retrieves a cached trie node pre-image from memory. If it cannot be found cached, the method queries the persistent database for the content.
func (*TrieDatabase) Reference ¶
func (db *TrieDatabase) Reference(child common.Hash, parent common.Hash)
Reference adds a new reference from a parent node to a child node.
func (*TrieDatabase) Size ¶
func (db *TrieDatabase) Size() common.StorageSize
Size returns the current storage size of the memory cache in front of the persistent database layer.
func (*TrieDatabase) UnLock ¶
func (db *TrieDatabase) UnLock()
type VTransaction ¶ added in v1.1.0
type VTransaction struct {
Tx *types.Transaction `json:"tx" gencodec:"required"`
St int64 `json:"time" gencodec:"required"`
}
func (VTransaction) MarshalJSON ¶ added in v1.1.0
func (v VTransaction) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*VTransaction) UnmarshalJSON ¶ added in v1.1.0
func (v *VTransaction) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type VTransactionDetail ¶ added in v1.1.0
type VTransactionDetail struct {
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
Height uint32 `json:"height" gencodec:"required"`
Tx *types.Transaction `json:"tx" gencodec:"required"`
St int64 `json:"time" gencodec:"required"`
}
func (VTransactionDetail) MarshalJSON ¶ added in v1.1.0
func (v VTransactionDetail) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*VTransactionDetail) UnmarshalJSON ¶ added in v1.1.0
func (v *VTransactionDetail) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type VoteTop ¶ added in v1.1.0
type VoteTop struct {
Top []*Candidate
}
func NewEmptyVoteTop ¶ added in v1.1.1
func NewEmptyVoteTop() *VoteTop