Documentation
¶
Index ¶
- Constants
- type Chain
- type Consensus
- type EventListener
- type FlushingBatch
- type LogItem
- type MemPool
- type Redo
- func (redo *Redo) AddLog(addr types.Address, log LogItem)
- func (redo *Redo) Close() error
- func (redo *Redo) HasRedo(snapshotHeight uint64) (bool, error)
- func (redo *Redo) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock)
- func (redo *Redo) QueryLog(snapshotHeight uint64) (SnapshotLog, bool, error)
- func (redo *Redo) Rollback(chunks []*ledger.SnapshotChunk)
- func (redo *Redo) SetCurrentSnapshot(snapshotHeight uint64, logMap SnapshotLog)
- type RedoCache
- func (redoCache *RedoCache) AddLog(addr types.Address, log LogItem)
- func (redoCache *RedoCache) Current() SnapshotLog
- func (redoCache *RedoCache) Delete(snapshotHeight uint64)
- func (redoCache *RedoCache) Get(snapshotHeight uint64) (SnapshotLog, bool)
- func (redoCache *RedoCache) Init(currentHeight uint64)
- func (redoCache *RedoCache) Set(snapshotHeight uint64, snapshotLog SnapshotLog)
- func (redoCache *RedoCache) SetCurrent(snapshotHeight uint64, snapshotLog SnapshotLog)
- type RedoCacheData
- type RedoInterface
- type RoundCache
- func (cache *RoundCache) DeleteSnapshotBlocks(snapshotBlocks []*ledger.SnapshotBlock) error
- func (cache *RoundCache) GetSnapshotViteBalanceList(snapshotHash types.Hash, addrList []types.Address) (map[types.Address]*big.Int, []types.Address, error)
- func (cache *RoundCache) Init(timeIndex core.TimeIndex) (returnErr error)
- func (cache *RoundCache) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, snapshotLog SnapshotLog) (returnErr error)
- func (cache *RoundCache) StorageIterator(snapshotHash types.Hash) interfaces.StorageIterator
- type RoundCacheInterface
- type RoundCacheLogItem
- type RoundCacheRedoLogs
- type RoundCacheSnapshotLog
- type SnapshotLog
- type StateDB
- func (sDB *StateDB) Close() error
- func (sDB *StateDB) GetBalance(addr types.Address, tokenTypeId types.TokenTypeId) (*big.Int, error)
- func (sDB *StateDB) GetBalanceMap(addr types.Address) (map[types.TokenTypeId]*big.Int, error)
- func (sDB *StateDB) GetCallDepth(sendBlockHash *types.Hash) (uint16, error)
- func (sDB *StateDB) GetCode(addr types.Address) ([]byte, error)
- func (sDB *StateDB) GetContractList(gid *types.Gid) ([]types.Address, error)
- func (sDB *StateDB) GetContractMeta(addr types.Address) (*ledger.ContractMeta, error)
- func (sDB *StateDB) GetSnapshotBalanceList(balanceMap map[types.Address]*big.Int, snapshotBlockHash types.Hash, ...) error
- func (sDB *StateDB) GetSnapshotValue(snapshotBlockHeight uint64, addr types.Address, key []byte) ([]byte, error)
- func (sDB *StateDB) GetStatus() []interfaces.DBStatus
- func (sDB *StateDB) GetStorageValue(addr *types.Address, key []byte) ([]byte, error)
- func (sDB *StateDB) GetVmLogList(logHash *types.Hash) (ledger.VmLogList, error)
- func (sDB *StateDB) HasContractMeta(addr types.Address) (bool, error)
- func (sDB *StateDB) Init() error
- func (sDB *StateDB) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock) error
- func (sDB *StateDB) IterateContracts(...)
- func (sDB *StateDB) NewRawSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) interfaces.StorageIterator
- func (sDB *StateDB) NewSnapshotStorageIterator(snapshotHash types.Hash, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
- func (sDB *StateDB) NewSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
- func (sDB *StateDB) NewStorageDatabase(snapshotHash types.Hash, addr types.Address) (StorageDatabaseInterface, error)
- func (sDB *StateDB) NewStorageIterator(addr types.Address, prefix []byte) interfaces.StorageIterator
- func (sDB *StateDB) Redo() RedoInterface
- func (sDB *StateDB) RedoStore() *chain_db.Store
- func (sDB *StateDB) RollbackAccountBlocks(accountBlocks []*ledger.AccountBlock) error
- func (sDB *StateDB) RollbackSnapshotBlocks(deletedSnapshotSegments []*ledger.SnapshotChunk, ...) error
- func (sDB *StateDB) SetCacheLevelForConsensus(level uint32)
- func (sDB *StateDB) SetConsensus(cs Consensus) error
- func (sDB *StateDB) Store() *chain_db.Store
- func (sDB *StateDB) Write(block *vm_db.VmAccountBlock) error
- func (sDB *StateDB) WriteByRedo(blockHash types.Hash, addr types.Address, redoLog LogItem)
- type StateDBInterface
- type StorageDatabase
- type StorageDatabaseInterface
- type TimeIndex
- type TransformIterator
- func (rcIter *TransformIterator) Error() error
- func (rcIter *TransformIterator) Key() []byte
- func (rcIter *TransformIterator) Last() bool
- func (rcIter *TransformIterator) Next() bool
- func (rcIter *TransformIterator) Prev() bool
- func (rcIter *TransformIterator) Release()
- func (rcIter *TransformIterator) Seek(key []byte) bool
- func (rcIter *TransformIterator) Value() []byte
Constants ¶
View Source
const ( STOP = 0 INITED = 1 )
View Source
const ( ConsensusNoCache = 0 ConsensusReadCache = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain interface {
IterateAccounts(iterateFunc func(addr types.Address, accountId uint64, err error) bool)
QueryLatestSnapshotBlock() (*ledger.SnapshotBlock, error)
GetLatestSnapshotBlock() *ledger.SnapshotBlock
GetSnapshotHeightByHash(hash types.Hash) (uint64, error)
GetUnconfirmedBlocks(addr types.Address) []*ledger.AccountBlock
GetAccountBlockByHash(blockHash types.Hash) (*ledger.AccountBlock, error)
GetSnapshotHeaderBeforeTime(timestamp *time.Time) (*ledger.SnapshotBlock, error)
GetSnapshotHeadersAfterOrEqualTime(endHashHeight *ledger.HashHeight, startTime *time.Time, producer *types.Address) ([]*ledger.SnapshotBlock, error)
// header without snapshot content
GetSnapshotHeaderByHeight(height uint64) (*ledger.SnapshotBlock, error)
StopWrite()
RecoverWrite()
}
type Consensus ¶
type Consensus interface {
VerifyAccountProducer(block *ledger.AccountBlock) (bool, error)
SBPReader() core.SBPStatReader
}
type EventListener ¶
type EventListener interface {
PrepareInsertAccountBlocks(blocks []*vm_db.VmAccountBlock) error
InsertAccountBlocks(blocks []*vm_db.VmAccountBlock) error
PrepareInsertSnapshotBlocks(snapshotBlocks []*ledger.SnapshotBlock) error
InsertSnapshotBlocks(snapshotBlocks []*ledger.SnapshotBlock) error
PrepareDeleteAccountBlocks(blocks []*ledger.AccountBlock) error
DeleteAccountBlocks(blocks []*ledger.AccountBlock) error
PrepareDeleteSnapshotBlocks(chunks []*ledger.SnapshotChunk) error
DeleteSnapshotBlocks(chunks []*ledger.SnapshotChunk) error
}
type LogItem ¶
type MemPool ¶
type MemPool struct {
// contains filtered or unexported fields
}
type Redo ¶
type Redo struct {
// contains filtered or unexported fields
}
func NewStorageRedoWithStore ¶
func (*Redo) InsertSnapshotBlock ¶
func (redo *Redo) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock)
func (*Redo) QueryLog ¶
func (redo *Redo) QueryLog(snapshotHeight uint64) (SnapshotLog, bool, error)
func (*Redo) Rollback ¶
func (redo *Redo) Rollback(chunks []*ledger.SnapshotChunk)
func (*Redo) SetCurrentSnapshot ¶
func (redo *Redo) SetCurrentSnapshot(snapshotHeight uint64, logMap SnapshotLog)
type RedoCache ¶
type RedoCache struct {
// contains filtered or unexported fields
}
func (*RedoCache) Current ¶
func (redoCache *RedoCache) Current() SnapshotLog
func (*RedoCache) Get ¶
func (redoCache *RedoCache) Get(snapshotHeight uint64) (SnapshotLog, bool)
func (*RedoCache) Set ¶
func (redoCache *RedoCache) Set(snapshotHeight uint64, snapshotLog SnapshotLog)
func (*RedoCache) SetCurrent ¶
func (redoCache *RedoCache) SetCurrent(snapshotHeight uint64, snapshotLog SnapshotLog)
type RedoCacheData ¶
type RedoCacheData struct {
// contains filtered or unexported fields
}
func NewRedoCacheData ¶
func NewRedoCacheData(roundIndex uint64, lastSnapshotBlock *ledger.SnapshotBlock, currentData *memdb.DB, redoLogs *RoundCacheRedoLogs) *RedoCacheData
type RedoInterface ¶
type RedoInterface interface {
Close() error
InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock)
HasRedo(snapshotHeight uint64) (bool, error)
QueryLog(snapshotHeight uint64) (SnapshotLog, bool, error)
SetCurrentSnapshot(snapshotHeight uint64, logMap SnapshotLog)
AddLog(addr types.Address, log LogItem)
Rollback(chunks []*ledger.SnapshotChunk)
// contains filtered or unexported methods
}
type RoundCache ¶
type RoundCache struct {
// contains filtered or unexported fields
}
func NewRoundCache ¶
func NewRoundCache(chain Chain, stateDB StateDBInterface, roundCount uint8) *RoundCache
func (*RoundCache) DeleteSnapshotBlocks ¶
func (cache *RoundCache) DeleteSnapshotBlocks(snapshotBlocks []*ledger.SnapshotBlock) error
panic when return error
func (*RoundCache) GetSnapshotViteBalanceList ¶
func (cache *RoundCache) GetSnapshotViteBalanceList(snapshotHash types.Hash, addrList []types.Address) (map[types.Address]*big.Int, []types.Address, error)
tokenId is viteTokenID
func (*RoundCache) Init ¶
func (cache *RoundCache) Init(timeIndex core.TimeIndex) (returnErr error)
build data
func (*RoundCache) InsertSnapshotBlock ¶
func (cache *RoundCache) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, snapshotLog SnapshotLog) (returnErr error)
panic when return error
func (*RoundCache) StorageIterator ¶
func (cache *RoundCache) StorageIterator(snapshotHash types.Hash) interfaces.StorageIterator
type RoundCacheInterface ¶
type RoundCacheInterface interface {
Init(timeIndex core.TimeIndex) (returnErr error)
InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, snapshotLog SnapshotLog) (returnErr error)
DeleteSnapshotBlocks(snapshotBlocks []*ledger.SnapshotBlock) error
GetSnapshotViteBalanceList(snapshotHash types.Hash, addrList []types.Address) (map[types.Address]*big.Int, []types.Address, error)
StorageIterator(snapshotHash types.Hash) interfaces.StorageIterator
// contains filtered or unexported methods
}
type RoundCacheLogItem ¶
type RoundCacheLogItem struct {
Storage [][2][]byte
BalanceMap map[types.TokenTypeId]*big.Int
}
type RoundCacheRedoLogs ¶
type RoundCacheRedoLogs struct {
Logs []*RoundCacheSnapshotLog
}
func NewRoundCacheRedoLogs ¶
func NewRoundCacheRedoLogs() *RoundCacheRedoLogs
func (*RoundCacheRedoLogs) Add ¶
func (redoLogs *RoundCacheRedoLogs) Add(snapshotHeight uint64, snapshotLog SnapshotLog)
type RoundCacheSnapshotLog ¶
type RoundCacheSnapshotLog struct {
LogMap map[types.Address][]RoundCacheLogItem
SnapshotHeight uint64
}
type SnapshotLog ¶
func (*SnapshotLog) Deserialize ¶
func (sl *SnapshotLog) Deserialize(buf []byte) error
func (*SnapshotLog) Serialize ¶
func (sl *SnapshotLog) Serialize() ([]byte, error)
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewStateDB ¶
func NewStateDBWithStore ¶
func (*StateDB) GetBalance ¶
func (*StateDB) GetBalanceMap ¶
func (*StateDB) GetCallDepth ¶
func (*StateDB) GetContractList ¶
func (*StateDB) GetContractMeta ¶
func (*StateDB) GetSnapshotBalanceList ¶
func (*StateDB) GetSnapshotValue ¶
func (*StateDB) GetStatus ¶
func (sDB *StateDB) GetStatus() []interfaces.DBStatus
func (*StateDB) GetStorageValue ¶
func (*StateDB) GetVmLogList ¶
func (*StateDB) HasContractMeta ¶
func (*StateDB) InsertSnapshotBlock ¶
func (sDB *StateDB) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock) error
func (*StateDB) IterateContracts ¶
func (*StateDB) NewRawSnapshotStorageIteratorByHeight ¶
func (sDB *StateDB) NewRawSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) interfaces.StorageIterator
func (*StateDB) NewSnapshotStorageIterator ¶
func (sDB *StateDB) NewSnapshotStorageIterator(snapshotHash types.Hash, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
func (*StateDB) NewSnapshotStorageIteratorByHeight ¶
func (sDB *StateDB) NewSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
func (*StateDB) NewStorageDatabase ¶
func (*StateDB) NewStorageIterator ¶
func (sDB *StateDB) NewStorageIterator(addr types.Address, prefix []byte) interfaces.StorageIterator
func (*StateDB) Redo ¶
func (sDB *StateDB) Redo() RedoInterface
func (*StateDB) RollbackAccountBlocks ¶
func (sDB *StateDB) RollbackAccountBlocks(accountBlocks []*ledger.AccountBlock) error
func (*StateDB) RollbackSnapshotBlocks ¶
func (sDB *StateDB) RollbackSnapshotBlocks(deletedSnapshotSegments []*ledger.SnapshotChunk, newUnconfirmedBlocks []*ledger.AccountBlock) error
func (*StateDB) SetCacheLevelForConsensus ¶
func (*StateDB) Write ¶
func (sDB *StateDB) Write(block *vm_db.VmAccountBlock) error
type StateDBInterface ¶
type StateDBInterface interface {
NewStorageIterator(addr types.Address, prefix []byte) interfaces.StorageIterator
NewSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
NewSnapshotStorageIterator(snapshotHash types.Hash, addr types.Address, prefix []byte) (interfaces.StorageIterator, error)
NewRawSnapshotStorageIteratorByHeight(snapshotHeight uint64, addr types.Address, prefix []byte) interfaces.StorageIterator
RollbackSnapshotBlocks(deletedSnapshotSegments []*ledger.SnapshotChunk, newUnconfirmedBlocks []*ledger.AccountBlock) error
RollbackAccountBlocks(accountBlocks []*ledger.AccountBlock) error
Init() error
Close() error
SetConsensus(cs Consensus) error
GetStorageValue(addr *types.Address, key []byte) ([]byte, error)
GetBalance(addr types.Address, tokenTypeId types.TokenTypeId) (*big.Int, error)
GetBalanceMap(addr types.Address) (map[types.TokenTypeId]*big.Int, error)
GetCode(addr types.Address) ([]byte, error)
GetContractMeta(addr types.Address) (*ledger.ContractMeta, error)
IterateContracts(iterateFunc func(addr types.Address, meta *ledger.ContractMeta, err error) bool)
HasContractMeta(addr types.Address) (bool, error)
GetContractList(gid *types.Gid) ([]types.Address, error)
GetVmLogList(logHash *types.Hash) (ledger.VmLogList, error)
GetCallDepth(sendBlockHash *types.Hash) (uint16, error)
GetSnapshotBalanceList(balanceMap map[types.Address]*big.Int, snapshotBlockHash types.Hash, addrList []types.Address, tokenId types.TokenTypeId) error
GetSnapshotValue(snapshotBlockHeight uint64, addr types.Address, key []byte) ([]byte, error)
SetCacheLevelForConsensus(level uint32)
Store() *chain_db.Store
RedoStore() *chain_db.Store
Redo() RedoInterface
GetStatus() []interfaces.DBStatus
NewStorageDatabase(snapshotHash types.Hash, addr types.Address) (StorageDatabaseInterface, error)
Write(block *vm_db.VmAccountBlock) error
WriteByRedo(blockHash types.Hash, addr types.Address, redoLog LogItem)
InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock) error
// contains filtered or unexported methods
}
type StorageDatabase ¶
type StorageDatabase struct {
// contains filtered or unexported fields
}
func (*StorageDatabase) Address ¶
func (sd *StorageDatabase) Address() *types.Address
func (*StorageDatabase) GetValue ¶
func (sd *StorageDatabase) GetValue(key []byte) ([]byte, error)
func (*StorageDatabase) NewStorageIterator ¶
func (sd *StorageDatabase) NewStorageIterator(prefix []byte) (interfaces.StorageIterator, error)
type StorageDatabaseInterface ¶
type StorageDatabaseInterface interface {
GetValue(key []byte) ([]byte, error)
NewStorageIterator(prefix []byte) (interfaces.StorageIterator, error)
Address() *types.Address
}
func NewStorageDatabase ¶
func NewStorageDatabase(stateDb *StateDB, hashHeight ledger.HashHeight, addr types.Address) StorageDatabaseInterface
type TimeIndex ¶
type TransformIterator ¶
type TransformIterator struct {
// contains filtered or unexported fields
}
func NewTransformIterator ¶
func NewTransformIterator(iter iterator.Iterator, keyPrefixLength int) *TransformIterator
func (*TransformIterator) Error ¶
func (rcIter *TransformIterator) Error() error
func (*TransformIterator) Key ¶
func (rcIter *TransformIterator) Key() []byte
func (*TransformIterator) Last ¶
func (rcIter *TransformIterator) Last() bool
func (*TransformIterator) Next ¶
func (rcIter *TransformIterator) Next() bool
func (*TransformIterator) Prev ¶
func (rcIter *TransformIterator) Prev() bool
func (*TransformIterator) Release ¶
func (rcIter *TransformIterator) Release()
func (*TransformIterator) Seek ¶
func (rcIter *TransformIterator) Seek(key []byte) bool
func (*TransformIterator) Value ¶
func (rcIter *TransformIterator) Value() []byte
Source Files
¶
- cache.go
- delete.go
- interface.go
- iteration.go
- redo.go
- redo_cache.go
- round_cache.go
- state_db.go
- storage_database.go
- transform_iterator.go
- write.go
Click to show internal directories.
Click to hide internal directories.