store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: LGPL-3.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const IdealBatchSize = 100 * 1024

Code using batches should try to add this much data to the batch. The value was determined empirically.

Variables

View Source
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)
)
View Source
var (
	DRIVER_MYSQL = "mysql"
	DNS_MYSQL    = "root:123123@tcp(localhost:3306)/lemochain?charset=utf8mb4"
)
View Source
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("")
)
View Source
var MbTable = []uint16{}/* 256 elements not displayed */
View Source
var OpenFileLimit = 64
View Source
var RHEAD_LENGTH = binary.Size(RHead{})

Functions

func Byte2Uint32

func Byte2Uint32(val []byte) uint32

func CheckSum

func CheckSum(data []byte) uint16

func ClearData

func ClearData()

func CreateBlock

func CreateBlock(hash common.Hash, parent common.Hash, height uint32) *types.Block

func CreateBufWithNumber

func CreateBufWithNumber(size int) ([]byte, error)

func CreateBufWithNumberBatch

func CreateBufWithNumberBatch(cnt int, template []byte) ([][]byte, error)

func CreateFile added in v1.1.0

func CreateFile(path string) error

func CreateSign

func CreateSign(cnt int) ([]types.SignData, error)

func Del added in v1.1.0

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

func Get added in v1.1.0

func Get(db *sql.DB, key string) ([]byte, error)

func GetAccount

func GetAccount(address string, balance int64, version uint32) *types.AccountData

func GetAccounts

func GetAccounts() []*types.AccountData

func GetBlock0

func GetBlock0() *types.Block

func GetBlock1

func GetBlock1() *types.Block

func GetBlock2

func GetBlock2() *types.Block

func GetBlock3 added in v1.1.0

func GetBlock3() *types.Block

func GetBlock4 added in v1.1.0

func GetBlock4() *types.Block

func GetBucketIndex

func GetBucketIndex(pos uint32) uint32

func GetItemIndex

func GetItemIndex(pos uint32) uint32

func GetPos

func GetPos(bucketIndex uint32, itemIndex uint32) uint32

func GetRandomString added in v1.1.0

func GetRandomString(len int) string

func GetStorePath

func GetStorePath() string

func InitTable added in v1.1.0

func InitTable(db *sql.DB)

func IsExist

func IsExist(path string) (bool, error)

func NewBlockBatch added in v1.1.0

func NewBlockBatch(size int) []*types.Block

func NewKey1

func NewKey1() ([]byte, uint32)

func NewKey2

func NewKey2() ([]byte, uint32)

func NewKey3

func NewKey3() ([]byte, uint32)

func Open added in v1.1.0

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

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

func Set added in v1.1.0

func Set(db *sql.DB, key string, val []byte) error

func TxGet8AddrNext added in v1.1.0

func TxGet8AddrNext(db *sql.DB, addr string, start int64, size int) ([][]byte, []int64, int64, error)

func TxGet8AddrPre added in v1.1.0

func TxGet8AddrPre(db *sql.DB, addr string, start int64, size int) ([][]byte, []int64, int64, error)

func TxGet8Hash added in v1.1.0

func TxGet8Hash(db *sql.DB, hash string) ([]byte, int64, error)

func TxSet added in v1.1.0

func TxSet(db *sql.DB, hash, from, to string, val []byte, ver int64, st int64) error

Types

type AfterScan added in v1.1.0

type AfterScan func(flag uint, route []byte, key []byte, val []byte, offset uint32) error

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 BatchItem

type BatchItem struct {
	Flg uint
	Key []byte
	Val []byte
}

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

func (*BeansDB) AfterScan added in v1.1.0

func (beansdb *BeansDB) AfterScan(flag uint, route []byte, key []byte, val []byte, offset uint32) error

func (*BeansDB) Close added in v1.1.0

func (beansdb *BeansDB) Close() error

func (*BeansDB) Commit added in v1.1.0

func (beansdb *BeansDB) Commit(batch Batch) error

func (*BeansDB) Get added in v1.1.0

func (beansdb *BeansDB) Get(key []byte) ([]byte, error)

func (*BeansDB) Has added in v1.1.0

func (beansdb *BeansDB) Has(key []byte) (bool, error)

func (*BeansDB) NewBatch added in v1.1.0

func (beansdb *BeansDB) NewBatch(route []byte) Batch

func (*BeansDB) Put added in v1.1.0

func (beansdb *BeansDB) Put(flg uint, route []byte, key []byte, val []byte) error

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

func NewBitCask(homePath string, lastIndex int, lastOffset uint32, after AfterScan, indexDB DB) (*BitCask, error)

func (*BitCask) Close added in v1.1.0

func (bitcask *BitCask) Close() error

func (*BitCask) Commit added in v1.1.0

func (bitcask *BitCask) Commit(batch Batch) error

func (*BitCask) Delete added in v1.1.0

func (bitcask *BitCask) Delete(flag int, route []byte, key []byte) error

func (*BitCask) Get added in v1.1.0

func (bitcask *BitCask) Get(flag uint, route []byte, key []byte, offset int64) ([]byte, error)

func (*BitCask) Get4Cache added in v1.1.0

func (bitcask *BitCask) Get4Cache(route []byte, key []byte) ([]byte, error)

func (*BitCask) NewBatch added in v1.1.0

func (bitcask *BitCask) NewBatch(route []byte) Batch

func (*BitCask) Put added in v1.1.0

func (bitcask *BitCask) Put(flag uint, route []byte, key []byte, val []byte) error

type BitcaskIndexes added in v1.1.0

type BitcaskIndexes [256]LastIndex

type BizAfterScan added in v1.1.0

type BizAfterScan func(flag uint, key []byte, val []byte) error

type BizDatabase added in v1.1.0

type BizDatabase struct {
	Reader   Reader
	Database *MySqlDB
}

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 BizDb added in v1.1.0

type BizDb interface {
	GetTxByHash(hash common.Hash) (*VTransactionDetail, error)

	GetTxByAddr(src common.Address, index int, size int) ([]*VTransaction, uint32, error)
}

type CBlock added in v1.1.0

type CBlock struct {
	Block *types.Block
	Trie  *PatriciaTrie
	Top30 []*Candidate
}

func (*CBlock) SetTop added in v1.1.0

func (block *CBlock) SetTop(src []*Candidate)

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

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

func (*Candidate) Clone added in v1.1.0

func (candidate *Candidate) Clone() *Candidate

func (*Candidate) GetAddress added in v1.1.0

func (candidate *Candidate) GetAddress() common.Address

func (*Candidate) GetNodeID added in v1.1.0

func (candidate *Candidate) GetNodeID() []byte

func (*Candidate) GetTotal added in v1.1.0

func (candidate *Candidate) GetTotal() *big.Int

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) *PatriciaTrie

func (*ChainDatabase) GetBizDatabase added in v1.1.0

func (database *ChainDatabase) GetBizDatabase() BizDb

func (*ChainDatabase) GetBlock added in v1.1.0

func (database *ChainDatabase) GetBlock(hash common.Hash, height uint32) (*types.Block, error)

func (*ChainDatabase) GetBlockByHash added in v1.1.0

func (database *ChainDatabase) GetBlockByHash(hash common.Hash) (*types.Block, error)

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 (database *ChainDatabase) GetCandidatesPage(index int, size int) ([]common.Address, uint32, error)

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 (database *ChainDatabase) GetConfirms(hash common.Hash) ([]types.SignData, error)

func (*ChainDatabase) GetContractCode added in v1.1.0

func (database *ChainDatabase) GetContractCode(hash common.Hash) (types.Code, error)

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) SetBlock added in v1.1.0

func (database *ChainDatabase) SetBlock(hash common.Hash, block *types.Block) error

func (*ChainDatabase) SetConfirm added in v1.1.0

func (database *ChainDatabase) SetConfirm(hash common.Hash, signData types.SignData) error

设置区块的确认信息 每次收到一个

func (*ChainDatabase) SetConfirms added in v1.1.0

func (database *ChainDatabase) SetConfirms(hash common.Hash, pack []types.SignData) error

func (*ChainDatabase) SetContractCode added in v1.1.0

func (database *ChainDatabase) SetContractCode(hash common.Hash, code types.Code) error

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 Commit added in v1.1.0

type Commit interface {
	Commit(batch Batch) error
}

type DB added in v1.1.0

type DB interface {
	DBWriter
	DBReader
}

type DBReader added in v1.1.0

type DBReader interface {
	GetIndex(key []byte) (int, []byte, int64, error)
}

type DBWriter added in v1.1.0

type DBWriter interface {
	SetIndex(flg int, route []byte, key []byte, offset int64) 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 Index

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

func (*Index) Bak

func (index *Index) Bak() int

func (*Index) Cur

func (index *Index) Cur() int

func (*Index) Init

func (index *Index) Init()

func (*Index) Swap

func (index *Index) Swap()

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) Has

func (db *LDBDatabase) Has(key []byte) (bool, error)

func (*LDBDatabase) NewBatch

func (db *LDBDatabase) NewBatch(route []byte) Batch

func (*LDBDatabase) Put

func (db *LDBDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the queue

type LastIndex added in v1.1.0

type LastIndex struct {
	Index  uint32
	Offset uint32
}

type LmBuffer

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

func NewLmBuffer

func NewLmBuffer(buf []byte) *LmBuffer

func (*LmBuffer) Read

func (buf *LmBuffer) Read(p []byte) (n int, err error)

func (*LmBuffer) Write

func (buf *LmBuffer) Write(p []byte) (n int, err error)

type LmDBBatch added in v1.1.0

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

func (*LmDBBatch) Commit added in v1.1.0

func (batch *LmDBBatch) Commit() error

func (*LmDBBatch) Items added in v1.1.0

func (batch *LmDBBatch) Items() []*BatchItem

func (*LmDBBatch) Put added in v1.1.0

func (batch *LmDBBatch) Put(flg uint, key, value []byte) error

func (*LmDBBatch) Reset added in v1.1.0

func (batch *LmDBBatch) Reset()

func (*LmDBBatch) Route added in v1.1.0

func (batch *LmDBBatch) Route() []byte

func (*LmDBBatch) ValueSize added in v1.1.0

func (batch *LmDBBatch) ValueSize() int

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) Get

func (db *MemDatabase) Get(key []byte) ([]byte, error)

func (*MemDatabase) Has

func (db *MemDatabase) Has(key []byte) (bool, 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

func (*MemDatabase) Put

func (db *MemDatabase) Put(key []byte, value []byte) error

type MySqlDB added in v1.1.0

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

func NewMySqlDB added in v1.1.0

func NewMySqlDB(driver string, dns string) *MySqlDB

func (*MySqlDB) Clear added in v1.1.0

func (db *MySqlDB) Clear() error

func (*MySqlDB) Close added in v1.1.0

func (db *MySqlDB) Close()

func (*MySqlDB) GetIndex added in v1.1.0

func (db *MySqlDB) GetIndex(key []byte) (int, []byte, int64, error)

func (*MySqlDB) SetIndex added in v1.1.0

func (db *MySqlDB) SetIndex(flg int, route []byte, key []byte, offset int64) error

func (*MySqlDB) TxGetByAddr added in v1.1.0

func (db *MySqlDB) TxGetByAddr(addr string, index int, size int) ([]string, [][]byte, []int64, error)

func (*MySqlDB) TxGetByHash added in v1.1.0

func (db *MySqlDB) TxGetByHash(key string) (string, []byte, int64, error)

func (*MySqlDB) TxSet added in v1.1.0

func (db *MySqlDB) TxSet(hash, blockHash, from, to string, val []byte, ver int64, st int64) error

type NewBatch added in v1.1.0

type NewBatch interface {
	NewBatch(route []byte) Batch
}

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(reader DatabaseReader, root *PatriciaTrie) *PatriciaTrie

func NewEmptyDatabase added in v1.1.0

func NewEmptyDatabase(reader DatabaseReader) *PatriciaTrie

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.AccountData

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 []byte) *types.AccountData

func (*PatriciaTrie) Insert added in v1.1.0

func (trie *PatriciaTrie) Insert(key []byte, data *types.AccountData) error

func (*PatriciaTrie) Put added in v1.1.0

func (trie *PatriciaTrie) Put(account *types.AccountData, dye uint32)

dye the node's path

type RBody added in v1.1.0

type RBody struct {
	Route []byte
	Key   []byte
	Val   []byte
}

type RHead added in v1.1.0

type RHead struct {
	Flg       uint32
	Len       uint32
	TimeStamp uint64
	Crc       uint16
}

type RIndex added in v1.1.0

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

type Reader added in v1.1.0

type Reader interface {
	GetLastConfirm() *CBlock

	GetBlockByHash(hash common.Hash) (*types.Block, error)
}

type RunContext added in v1.1.0

type RunContext struct {
	Path        string
	StableBlock *types.Block
	Candidates  map[common.Address]bool
}

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 (context *RunContext) GetCandidatePage(index int, size int) ([]common.Address, uint32, 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(address common.Address)

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 {
	TopCnt int
	Top    []*Candidate
}

func NewVoteTop added in v1.1.0

func NewVoteTop(top []*Candidate) *VoteTop

func (*VoteTop) Clear added in v1.1.0

func (top *VoteTop) Clear()

func (*VoteTop) Clone added in v1.1.0

func (top *VoteTop) Clone() *VoteTop

func (*VoteTop) Count added in v1.1.0

func (top *VoteTop) Count() int

func (*VoteTop) Del added in v1.1.0

func (top *VoteTop) Del(address common.Address)

func (*VoteTop) GetTop added in v1.1.0

func (top *VoteTop) GetTop() []*Candidate

func (*VoteTop) Max added in v1.1.0

func (top *VoteTop) Max() *Candidate

func (*VoteTop) Min added in v1.1.0

func (top *VoteTop) Min() *Candidate

func (*VoteTop) Rank added in v1.1.0

func (top *VoteTop) Rank(topSize int, candidates []*Candidate)

func (*VoteTop) Reset added in v1.1.0

func (top *VoteTop) Reset(candidates []*Candidate)

Directories

Path Synopsis
Package trie implements Merkle Patricia Tries.
Package trie implements Merkle Patricia Tries.

Jump to

Keyboard shortcuts

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