Documentation ¶
Index ¶
- Constants
- Variables
- type CommitData
- type Config
- type DataEntryPrefix
- type Getter
- type LevelDBStore
- func (self *LevelDBStore) BatchCommit() error
- func (self *LevelDBStore) BatchDelete(key []byte)
- func (self *LevelDBStore) BatchPut(key []byte, value []byte)
- func (self *LevelDBStore) Close() error
- func (self *LevelDBStore) Delete(key []byte) error
- func (self *LevelDBStore) Get(key []byte) ([]byte, error)
- func (self *LevelDBStore) Has(key []byte) (bool, error)
- func (self *LevelDBStore) NewBatch()
- func (self *LevelDBStore) NewIterator(prefix []byte) StoreIterator
- func (self *LevelDBStore) Put(key []byte, value []byte) error
- type PersistStore
- type Setter
- type Storage
- func (strg *Storage) Commit(data *CommitData) error
- func (strg *Storage) GetBlock(hash []byte) (*core.Block, error)
- func (strg *Storage) GetBlockByHeight(height uint64) (*core.Block, error)
- func (strg *Storage) GetBlockCommit(hash []byte) (*core.BlockCommit, error)
- func (strg *Storage) GetBlockHeight() uint64
- func (strg *Storage) GetLastBlock() (*core.Block, error)
- func (strg *Storage) GetLastQC() (*core.QuorumCert, error)
- func (strg *Storage) GetMerkleRoot() []byte
- func (strg *Storage) GetQC(blkHash []byte) (*core.QuorumCert, error)
- func (strg *Storage) GetState(key []byte) []byte
- func (strg *Storage) GetTx(hash []byte) (*core.Transaction, error)
- func (strg *Storage) GetTxCommit(hash []byte) (*core.TxCommit, error)
- func (strg *Storage) HasTx(hash []byte) bool
- func (strg *Storage) StoreBlock(blk *core.Block) error
- func (strg *Storage) StoreQC(qc *core.QuorumCert) error
- func (strg *Storage) VerifyState(key []byte) []byte
- type StoreIterator
Constants ¶
View Source
const BITSPERKEY = 10
used to compute the size of bloom filter bits array . too small will lead to high false positive rate.
Variables ¶
View Source
var DefaultConfig = Config{
MerkleBranchFactor: 8,
ConcurrentLimit: 20,
}
Functions ¶
This section is empty.
Types ¶
type CommitData ¶
type CommitData struct { Block *core.Block Transactions []*core.Transaction BlockCommit *core.BlockCommit TxCommits []*core.TxCommit // contains filtered or unexported fields }
type DataEntryPrefix ¶
type DataEntryPrefix byte
const ( BLOCK_BY_HASH DataEntryPrefix = iota + 1 // block by hash BLOCK_HASH_BY_HEIGHT // block hash by height BLOCK_HEIGHT // last block height QC_BY_BLOCK_HASH // qc by block hash LAST_QC_BLOCK_HASH // qc for last committed block to be used on restart BLOCK_COMMIT_BY_HASH // block commit by block hash TX_COUNT // total committed tx count TX_BY_HASH // tx by hash TX_COMMIT_BY_HASH // tx commit info by tx hash STATE_VALUE_BY_KEY // state value by state key MERKLE_INDEX_BY_STATE_KEY // tree leaf index by state key MERKLE_TREE_HEIGHT // tree height MERKLE_LEAF_COUNT // tree leaf count MERKLE_NODE_BY_POSITION // tree node value by position BOOK_KEEPER // BookKeeper state key prefix CONTRACT // Smart contract deploy code key prefix STORAGE // Smart contract storage key prefix DESTROYED // record destroyed smart contract: prefix+address -> height ETH_CODE // eth contract code:hash -> bytes ETH_ACCOUNT // eth account: address -> [nonce, codeHash] ETH_FILTER_START // support eth filter height )
data collection prefixes for different data collections
type LevelDBStore ¶
type LevelDBStore struct {
// contains filtered or unexported fields
}
LevelDB store
func NewLevelDBStore ¶
func NewLevelDBStore(file string) (*LevelDBStore, error)
NewLevelDBStore return LevelDBStore instance
func NewMemLevelDBStore ¶
func NewMemLevelDBStore() *LevelDBStore
func (*LevelDBStore) BatchCommit ¶
func (self *LevelDBStore) BatchCommit() error
BatchCommit commit batch to leveldb
func (*LevelDBStore) BatchDelete ¶
func (self *LevelDBStore) BatchDelete(key []byte)
BatchDelete delete a key to leveldb batch
func (*LevelDBStore) BatchPut ¶
func (self *LevelDBStore) BatchPut(key []byte, value []byte)
BatchPut put a key-value pair to leveldb batch
func (*LevelDBStore) Delete ¶
func (self *LevelDBStore) Delete(key []byte) error
Delete the key in leveldb
func (*LevelDBStore) Get ¶
func (self *LevelDBStore) Get(key []byte) ([]byte, error)
Get the value of a key from leveldb
func (*LevelDBStore) Has ¶
func (self *LevelDBStore) Has(key []byte) (bool, error)
Has return whether the key exists in leveldb
func (*LevelDBStore) NewIterator ¶
func (self *LevelDBStore) NewIterator(prefix []byte) StoreIterator
NewIterator return a iterator of leveldb with the key prefix
type PersistStore ¶
type PersistStore interface { Put(key []byte, value []byte) error // Put the key-value pair to store Get(key []byte) ([]byte, error) // Get the value if key in store Has(key []byte) (bool, error) // Whether the key is exist in store Delete(key []byte) error // Delete the key in store NewBatch() // Start commit batch BatchPut(key []byte, value []byte) // Put a key-value pair to batch BatchDelete(key []byte) // Delete the key in batch BatchCommit() error // Commit batch to store Close() error // Close store NewIterator(prefix []byte) StoreIterator // Return the iterator of store }
PersistStore of ledger
type Storage ¶
type Storage struct { PersistStore PersistStore // contains filtered or unexported fields }
func (*Storage) Commit ¶
func (strg *Storage) Commit(data *CommitData) error
func (*Storage) GetBlockByHeight ¶
func (*Storage) GetBlockCommit ¶
func (strg *Storage) GetBlockCommit(hash []byte) (*core.BlockCommit, error)
func (*Storage) GetBlockHeight ¶
func (*Storage) GetMerkleRoot ¶
func (*Storage) VerifyState ¶
type StoreIterator ¶
type StoreIterator interface { Next() bool // Next item. If item available return true, otherwise return false First() bool // First item. If item available return true, otherwise return false Key() []byte // Return the current item key Value() []byte // Return the current item value Release() // Close iterator Error() error // Error returns any accumulated error. }
Click to show internal directories.
Click to hide internal directories.