chain_state

package
v0.0.0-...-96daba7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain interface {
	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)
}

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 FlushingBatch

type FlushingBatch struct {
	Operation byte
	Batch     *leveldb.Batch
}

type LogItem

type LogItem struct {
	Storage      [][2][]byte
	BalanceMap   map[types.TokenTypeId]*big.Int
	Code         []byte
	ContractMeta map[types.Address][]byte
	VmLogList    map[types.Hash][]byte
	CallDepth    map[types.Hash]uint16
	Height       uint64
}

type Redo

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

func NewStorageRedoWithStore

func NewStorageRedoWithStore(chain Chain, store *chain_db.Store) (*Redo, error)

func (*Redo) AddLog

func (redo *Redo) AddLog(addr types.Address, log LogItem)

func (*Redo) Close

func (redo *Redo) Close() error

func (*Redo) HasRedo

func (redo *Redo) HasRedo(snapshotHeight uint64) (bool, error)

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 NewRedoCache

func NewRedoCache() *RedoCache

func (*RedoCache) AddLog

func (redoCache *RedoCache) AddLog(addr types.Address, log LogItem)

func (*RedoCache) Current

func (redoCache *RedoCache) Current() SnapshotLog

func (*RedoCache) Delete

func (redoCache *RedoCache) Delete(snapshotHeight uint64)

func (*RedoCache) Get

func (redoCache *RedoCache) Get(snapshotHeight uint64) (SnapshotLog, bool)

func (*RedoCache) Init

func (redoCache *RedoCache) Init(currentHeight uint64)

func (*RedoCache) Set

func (redoCache *RedoCache) Set(snapshotHeight uint64, snapshotLog SnapshotLog)

func (*RedoCache) SetCurrent

func (redoCache *RedoCache) SetCurrent(snapshotHeight uint64, snapshotLog SnapshotLog)

type SnapshotLog

type SnapshotLog map[types.Address][]LogItem

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 NewStateDB(chain Chain, chainCfg *config.Chain, chainDir string) (*StateDB, error)

func NewStateDBWithStore

func NewStateDBWithStore(chain Chain, chainCfg *config.Chain, store *chain_db.Store, redoStore *chain_db.Store) (*StateDB, error)

func (*StateDB) Close

func (sDB *StateDB) Close() error

func (*StateDB) GetBalance

func (sDB *StateDB) GetBalance(addr types.Address, tokenTypeId types.TokenTypeId) (*big.Int, error)

func (*StateDB) GetBalanceMap

func (sDB *StateDB) GetBalanceMap(addr types.Address) (map[types.TokenTypeId]*big.Int, error)

func (*StateDB) GetCallDepth

func (sDB *StateDB) GetCallDepth(sendBlockHash *types.Hash) (uint16, error)

func (*StateDB) GetCode

func (sDB *StateDB) GetCode(addr types.Address) ([]byte, error)

func (*StateDB) GetContractList

func (sDB *StateDB) GetContractList(gid *types.Gid) ([]types.Address, error)

func (*StateDB) GetContractMeta

func (sDB *StateDB) GetContractMeta(addr types.Address) (*ledger.ContractMeta, error)

func (*StateDB) GetSnapshotBalanceList

func (sDB *StateDB) GetSnapshotBalanceList(snapshotBlockHash types.Hash, addrList []types.Address, tokenId types.TokenTypeId) (map[types.Address]*big.Int, error)

func (*StateDB) GetSnapshotValue

func (sDB *StateDB) GetSnapshotValue(snapshotBlockHeight uint64, addr types.Address, key []byte) ([]byte, error)

func (*StateDB) GetStatus

func (sDB *StateDB) GetStatus() []interfaces.DBStatus

func (*StateDB) GetStorageValue

func (sDB *StateDB) GetStorageValue(addr *types.Address, key []byte) ([]byte, error)

func (*StateDB) GetVmLogList

func (sDB *StateDB) GetVmLogList(logHash *types.Hash) (ledger.VmLogList, error)

func (*StateDB) HasContractMeta

func (sDB *StateDB) HasContractMeta(addr types.Address) (bool, error)

func (*StateDB) Init

func (sDB *StateDB) Init() error

func (*StateDB) InsertSnapshotBlock

func (sDB *StateDB) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock, confirmedBlocks []*ledger.AccountBlock) error

func (*StateDB) IterateContracts

func (sDB *StateDB) IterateContracts(iterateFunc func(addr types.Address, meta *ledger.ContractMeta, err error) bool)

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 (sDB *StateDB) NewStorageDatabase(snapshotHash types.Hash, addr types.Address) (*StorageDatabase, error)

func (*StateDB) NewStorageIterator

func (sDB *StateDB) NewStorageIterator(addr *types.Address, prefix []byte) interfaces.StorageIterator

func (*StateDB) RedoStore

func (sDB *StateDB) RedoStore() *chain_db.Store

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

func (sDB *StateDB) StorageRedo() *Redo

func (*StateDB) Store

func (sDB *StateDB) Store() *chain_db.Store

func (*StateDB) Write

func (sDB *StateDB) Write(block *vm_db.VmAccountBlock) error

func (*StateDB) WriteByRedo

func (sDB *StateDB) WriteByRedo(blockHash types.Hash, addr types.Address, redoLog LogItem)

type StorageDatabase

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

func NewStorageDatabase

func NewStorageDatabase(stateDb *StateDB, snapshotHeight uint64, addr types.Address) *StorageDatabase

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)

Jump to

Keyboard shortcuts

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