vm_db

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: 13 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 {
	IsContractAccount(address types.Address) (bool, error)

	GetQuotaUsedList(address types.Address) []types.QuotaInfo

	GetGlobalQuota() types.QuotaInfo

	GetBalance(addr types.Address, tokenId types.TokenTypeId) (*big.Int, error)

	GetContractCode(contractAddr types.Address) ([]byte, error)

	GetContractMeta(contractAddress types.Address) (meta *ledger.ContractMeta, err error)

	GetConfirmSnapshotHeaderByAbHash(abHash types.Hash) (*ledger.SnapshotBlock, error)

	GetConfirmedTimes(blockHash types.Hash) (uint64, error)

	GetContractMetaInSnapshot(contractAddress types.Address, snapshotHeight uint64) (meta *ledger.ContractMeta, err error)

	GetSnapshotHeaderByHash(hash types.Hash) (*ledger.SnapshotBlock, error)

	GetAccountBlockByHash(blockHash types.Hash) (*ledger.AccountBlock, error)

	GetLatestAccountBlock(addr types.Address) (*ledger.AccountBlock, error)

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

	GetUnconfirmedBlocks(addr types.Address) []*ledger.AccountBlock

	GetGenesisSnapshotBlock() *ledger.SnapshotBlock

	GetPledgeBeneficialAmount(addr types.Address) (*big.Int, error)

	GetStorageIterator(address types.Address, prefix []byte) (interfaces.StorageIterator, error)

	GetValue(addr types.Address, key []byte) ([]byte, error)

	GetCallDepth(sendBlockHash types.Hash) (uint16, error)

	GetSnapshotBlockByContractMeta(addr types.Address, fromHash types.Hash) (*ledger.SnapshotBlock, error)

	GetSeedConfirmedSnapshotBlock(addr types.Address, fromHash types.Hash) (*ledger.SnapshotBlock, error)

	GetSeed(limitSb *ledger.SnapshotBlock, fromHash types.Hash) (uint64, error)
}

type Unsaved

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

func NewUnsaved

func NewUnsaved() *Unsaved

func (*Unsaved) AddLog

func (unsaved *Unsaved) AddLog(log *ledger.VmLog)

func (*Unsaved) GetBalance

func (unsaved *Unsaved) GetBalance(tokenTypeId *types.TokenTypeId) (*big.Int, bool)

func (*Unsaved) GetBalanceMap

func (unsaved *Unsaved) GetBalanceMap() map[types.TokenTypeId]*big.Int

func (*Unsaved) GetCode

func (unsaved *Unsaved) GetCode() []byte

func (*Unsaved) GetContractMeta

func (unsaved *Unsaved) GetContractMeta(addr types.Address) *ledger.ContractMeta

func (*Unsaved) GetLogList

func (unsaved *Unsaved) GetLogList() ledger.VmLogList

func (*Unsaved) GetLogListHash

func (unsaved *Unsaved) GetLogListHash(snapshotBlockHeight uint64, address types.Address, prevHash types.Hash) *types.Hash

func (*Unsaved) GetStorage

func (unsaved *Unsaved) GetStorage() [][2][]byte

func (*Unsaved) GetValue

func (unsaved *Unsaved) GetValue(key []byte) ([]byte, bool)

func (*Unsaved) IsDelete

func (unsaved *Unsaved) IsDelete(key []byte) bool

func (*Unsaved) NewStorageIterator

func (unsaved *Unsaved) NewStorageIterator(prefix []byte) interfaces.StorageIterator

func (*Unsaved) ReleaseRuntime

func (unsaved *Unsaved) ReleaseRuntime()

func (*Unsaved) Reset

func (unsaved *Unsaved) Reset()

func (*Unsaved) SetBalance

func (unsaved *Unsaved) SetBalance(tokenTypeId *types.TokenTypeId, amount *big.Int)

func (*Unsaved) SetCode

func (unsaved *Unsaved) SetCode(code []byte)

func (*Unsaved) SetContractMeta

func (unsaved *Unsaved) SetContractMeta(addr types.Address, contractMeta *ledger.ContractMeta)

func (*Unsaved) SetValue

func (unsaved *Unsaved) SetValue(key []byte, value []byte)

type VmAccountBlock

type VmAccountBlock struct {
	AccountBlock *ledger.AccountBlock
	VmDb         VmDb
}

type VmDb

type VmDb interface {
	// ====== Context ======
	CanWrite() bool

	Address() *types.Address

	LatestSnapshotBlock() (*ledger.SnapshotBlock, error)

	PrevAccountBlock() (*ledger.AccountBlock, error)

	GetLatestAccountBlock(addr types.Address) (*ledger.AccountBlock, error)

	IsContractAccount() (bool, error)

	GetCallDepth(sendBlockHash *types.Hash) (uint16, error)

	GetQuotaUsedList(addr types.Address) []types.QuotaInfo

	GetGlobalQuota() types.QuotaInfo

	// ====== State ======
	GetReceiptHash() *types.Hash

	Reset()

	// Release memory used in runtime.
	Finish()

	// ====== Storage ======
	GetValue(key []byte) ([]byte, error)

	GetOriginalValue(key []byte) ([]byte, error)

	SetValue(key []byte, value []byte) error

	NewStorageIterator(prefix []byte) (interfaces.StorageIterator, error)

	GetUnsavedStorage() [][2][]byte

	// ====== Balance ======
	GetBalance(tokenTypeId *types.TokenTypeId) (*big.Int, error)
	SetBalance(tokenTypeId *types.TokenTypeId, amount *big.Int)

	GetUnsavedBalanceMap() map[types.TokenTypeId]*big.Int

	// ====== VMLog ======
	AddLog(log *ledger.VmLog)

	GetLogList() ledger.VmLogList
	GetHistoryLogList(logHash *types.Hash) (ledger.VmLogList, error)
	GetLogListHash() *types.Hash

	// ====== AccountBlock ======
	GetUnconfirmedBlocks(address types.Address) []*ledger.AccountBlock

	// ====== SnapshotBlock ======
	GetGenesisSnapshotBlock() *ledger.SnapshotBlock

	GetConfirmSnapshotHeader(blockHash types.Hash) (*ledger.SnapshotBlock, error)

	GetConfirmedTimes(blockHash types.Hash) (uint64, error)

	// ====== Meta & Code ======
	SetContractMeta(toAddr types.Address, meta *ledger.ContractMeta)

	GetContractMeta() (*ledger.ContractMeta, error)

	GetContractMetaInSnapshot(contractAddress types.Address, snapshotBlock *ledger.SnapshotBlock) (meta *ledger.ContractMeta, err error)

	SetContractCode(code []byte)

	GetContractCode() ([]byte, error)

	GetContractCodeBySnapshotBlock(addr *types.Address, snapshotBlock *ledger.SnapshotBlock) ([]byte, error) // TODO

	GetUnsavedContractMeta() map[types.Address]*ledger.ContractMeta

	GetUnsavedContractCode() []byte

	// ====== built-in contract ======
	GetPledgeBeneficialAmount(addr *types.Address) (*big.Int, error)

	// ====== debug ======
	DebugGetStorage() (map[string][]byte, error)
}

func NewGenesisVmDB

func NewGenesisVmDB(address *types.Address) VmDb

func NewNoContextVmDb

func NewNoContextVmDb(chain Chain) VmDb

func NewVmDb

func NewVmDb(chain Chain, address *types.Address, latestSnapshotBlockHash *types.Hash, prevAccountBlockHash *types.Hash) (VmDb, error)

func NewVmDbByAddr

func NewVmDbByAddr(chain Chain, address *types.Address) VmDb

Jump to

Keyboard shortcuts

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