storage

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MPL-2.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceHandle

type BalanceHandle interface {
	SubBalance(cache *CacheDB, addr web3.Address, val *big.Int) error
	AddBalance(cache *CacheDB, addr web3.Address, val *big.Int) error
	SetBalance(cache *CacheDB, addr web3.Address, val *big.Int) error
	GetBalance(cache *CacheDB, addr web3.Address) (*big.Int, error)
}

type CacheDB

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

CacheDB is smart contract execute cache, it contain transaction cache and block cache When smart contract execute finish, need to commit transaction cache to block cache

func NewCacheDB

func NewCacheDB(store *overlaydb.OverlayDB) *CacheDB

NewCacheDB return a new contract cache

func (*CacheDB) CleanContractStorageData

func (self *CacheDB) CleanContractStorageData(addr web3.Address) error

func (*CacheDB) Commit

func (self *CacheDB) Commit()

Commit current transaction cache to block cache

func (*CacheDB) DelEthAccount

func (self *CacheDB) DelEthAccount(addr web3.Address)

func (*CacheDB) Delete

func (self *CacheDB) Delete(key []byte)

func (*CacheDB) GenAccountStateKey

func (self *CacheDB) GenAccountStateKey(addr web3.Address, key []byte) []byte

func (*CacheDB) Get

func (self *CacheDB) Get(key []byte) ([]byte, error)

func (*CacheDB) GetEthAccount

func (self *CacheDB) GetEthAccount(addr web3.Address) (val EthAccount, err error)

func (*CacheDB) NewIterator

func (self *CacheDB) NewIterator(key []byte) schema.StoreIterator

func (*CacheDB) Put

func (self *CacheDB) Put(key []byte, value []byte)

func (*CacheDB) PutEthAccount

func (self *CacheDB) PutEthAccount(addr web3.Address, val EthAccount)

func (*CacheDB) Reset

func (self *CacheDB) Reset()

func (*CacheDB) SetDbErr

func (self *CacheDB) SetDbErr(err error)

type EthAccount

type EthAccount struct {
	Nonce    uint64
	Balance  *uint256.Int
	Code     hexutil.Bytes
	CodeHash web3.Hash
}

func (*EthAccount) Deserialization

func (self *EthAccount) Deserialization(source *codec.ZeroCopySource) error

func (*EthAccount) IsEmpty

func (self *EthAccount) IsEmpty() bool

func (*EthAccount) Serialization

func (self *EthAccount) Serialization(sink *codec.ZeroCopySink)

type FakeDB added in v0.1.7

type FakeDB struct {
	schema.PersistStore
}

func NewFakeDB added in v0.1.7

func NewFakeDB() *FakeDB

func (*FakeDB) Get added in v0.1.7

func (self *FakeDB) Get(key []byte) ([]byte, error)

func (*FakeDB) GetBlockHash added in v0.1.7

func (self *FakeDB) GetBlockHash(height uint64) web3.Hash

func (*FakeDB) NewIterator added in v0.1.11

func (self *FakeDB) NewIterator(prefix []byte) schema.StoreIterator

type Iter

type Iter struct {
	*overlaydb.JoinIter
}

func (*Iter) Key

func (self *Iter) Key() []byte

type StateDB

type StateDB struct {
	Suicided map[web3.Address]bool

	BalanceHandle BalanceHandle
	// contains filtered or unexported fields
}

func NewStateDB

func NewStateDB(cacheDB *CacheDB) *StateDB

func (*StateDB) AddBalance

func (self *StateDB) AddBalance(addr web3.Address, val *big.Int)

func (*StateDB) AddLog

func (self *StateDB) AddLog(log *web3.StorageLog)

func (*StateDB) AddPreimage

func (self *StateDB) AddPreimage(web3.Hash, []byte)

func (*StateDB) AddRefund

func (self *StateDB) AddRefund(gas uint64)

func (*StateDB) Commit

func (self *StateDB) Commit() error

func (*StateDB) CommitToCacheDB

func (self *StateDB) CommitToCacheDB() error

func (*StateDB) CreateAccount

func (self *StateDB) CreateAccount(web3.Address)

func (*StateDB) DbErr

func (self *StateDB) DbErr() error

func (*StateDB) DiscardSnapshot added in v0.1.7

func (self *StateDB) DiscardSnapshot(idx int)

func (*StateDB) Empty

func (self *StateDB) Empty(addr web3.Address) bool

func (*StateDB) Exist

func (self *StateDB) Exist(addr web3.Address) bool

func (*StateDB) ForEachStorage

func (self *StateDB) ForEachStorage(addr web3.Address, fn func(web3.Hash, web3.Hash) bool) error

func (*StateDB) GetBalance

func (self *StateDB) GetBalance(addr web3.Address) *big.Int

func (*StateDB) GetCode

func (self *StateDB) GetCode(addr web3.Address) []byte

func (*StateDB) GetCodeHash

func (self *StateDB) GetCodeHash(addr web3.Address) (hash web3.Hash)

func (*StateDB) GetCodeSize

func (self *StateDB) GetCodeSize(addr web3.Address) int

func (*StateDB) GetCommittedState

func (self *StateDB) GetCommittedState(addr web3.Address, key web3.Hash) web3.Hash

func (*StateDB) GetLogs

func (self *StateDB) GetLogs() []*web3.StorageLog

func (*StateDB) GetNonce

func (self *StateDB) GetNonce(addr web3.Address) uint64

func (*StateDB) GetRefund

func (self *StateDB) GetRefund() uint64

GetRefund returns the current value of the refund counter.

func (*StateDB) GetState

func (self *StateDB) GetState(contract web3.Address, key web3.Hash) web3.Hash

func (*StateDB) HasSuicided

func (self *StateDB) HasSuicided(addr web3.Address) bool

func (*StateDB) RevertToSnapshot

func (self *StateDB) RevertToSnapshot(idx int)

func (*StateDB) SetCode

func (self *StateDB) SetCode(addr web3.Address, code []byte)

func (*StateDB) SetNonce

func (self *StateDB) SetNonce(addr web3.Address, nonce uint64)

func (*StateDB) SetState

func (self *StateDB) SetState(contract web3.Address, key, value web3.Hash)

func (*StateDB) Snapshot

func (self *StateDB) Snapshot() int

func (*StateDB) SubBalance

func (self *StateDB) SubBalance(addr web3.Address, val *big.Int)

func (*StateDB) SubRefund

func (self *StateDB) SubRefund(gas uint64)

SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero

func (*StateDB) Suicide

func (self *StateDB) Suicide(addr web3.Address) bool

Directories

Path Synopsis
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.

Jump to

Keyboard shortcuts

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