Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBalanceInsufficient = errors.New("cannot subtract a value which is bigger than current balance") ErrAccountNotFound = errors.New("cannot found account in storage") ErrContractAccountNotFound = errors.New("cannot found contract account in storage please check contract address is valid or deploy is success") )
Errors
View Source
var ( ErrCannotPrepareTxStateTwice = errors.New("cannot prepare tx state twice") ErrCannotCloneOngoingWorldState = errors.New("cannot clone an ongoing world state") ErrCannotBeginWorldStateTwice = errors.New("cannot begin a world state twice") ErrCannotCommitWorldStateBeforeBegin = errors.New("cannot commit a world state before begin") ErrCannotRollBackWorldStateBeforeBegin = errors.New("cannot rollback a world state before begin") ErrCannotPrepareTxStateBeforeBegin = errors.New("cannot prepare a tx state before begin") ErrCannotCheckTxStateBeforePrepare = errors.New("cannot check a tx state before prepare") ErrCannotUpdateTxStateBeforePrepare = errors.New("cannot update a tx state before prepare") ErrCannotResetTxStateBeforePrepare = errors.New("cannot reset a tx state before prepare") ErrContractCheckFailed = errors.New("contract check failed") )
Errors
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { Address() byteutils.Hash Balance() *util.Uint128 Nonce() uint64 BirthPlace() byteutils.Hash VarsHash() byteutils.Hash Clone() (Account, error) ToBytes() ([]byte, error) FromBytes(bytes []byte, storage storage.Storage) error IncrNonce() AddBalance(value *util.Uint128) error SubBalance(value *util.Uint128) error Put(key []byte, value []byte) error Get(key []byte) ([]byte, error) Del(key []byte) error Iterator(prefix []byte) (Iterator, error) ContractMeta() *corepb.ContractMeta }
Account Interface
func MockAccount ¶ added in v1.0.5
MockAccount nf/nvm/engine.CheckV8Run() & cmd/v8/main.go
type AccountState ¶
type AccountState interface { RootHash() byteutils.Hash Flush() error Abort() error DirtyAccounts() ([]Account, error) Accounts() ([]Account, error) Clone() (AccountState, error) Replay(AccountState) error GetOrCreateUserAccount(byteutils.Hash) (Account, error) GetContractAccount(byteutils.Hash) (Account, error) CreateContractAccount(byteutils.Hash, byteutils.Hash, *corepb.ContractMeta) (Account, error) }
AccountState Interface
func NewAccountState ¶
NewAccountState create a new account state
type Consensus ¶
type Consensus interface {
NewState(*consensuspb.ConsensusRoot, storage.Storage, bool) (ConsensusState, error)
}
Consensus interface
type ConsensusState ¶
type ConsensusState interface { RootHash() *consensuspb.ConsensusRoot String() string Clone() (ConsensusState, error) Replay(ConsensusState) error Proposer() byteutils.Hash TimeStamp() int64 NextConsensusState(int64, WorldState) (ConsensusState, error) Dynasty() ([]byteutils.Hash, error) DynastyRoot() byteutils.Hash }
ConsensusState interface of consensus state
type TxWorldState ¶
type TxWorldState interface { AccountsRoot() byteutils.Hash TxsRoot() byteutils.Hash EventsRoot() byteutils.Hash ConsensusRoot() *consensuspb.ConsensusRoot CheckAndUpdate() ([]interface{}, error) Reset(addr byteutils.Hash, isResetChangeLog bool) error Close() error Accounts() ([]Account, error) GetOrCreateUserAccount(addr byteutils.Hash) (Account, error) GetContractAccount(addr byteutils.Hash) (Account, error) CreateContractAccount(owner byteutils.Hash, birthPlace byteutils.Hash, contractMeta *corepb.ContractMeta) (Account, error) GetTx(txHash byteutils.Hash) ([]byte, error) PutTx(txHash byteutils.Hash, txBytes []byte) error RecordEvent(txHash byteutils.Hash, event *Event) FetchEvents(byteutils.Hash) ([]*Event, error) Dynasty() ([]byteutils.Hash, error) DynastyRoot() byteutils.Hash RecordGas(from string, gas *util.Uint128) error GetBlockHashByHeight(height uint64) ([]byte, error) GetBlock(txHash byteutils.Hash) ([]byte, error) }
TxWorldState is the world state of a single transaction
type WorldState ¶
type WorldState interface { Begin() error Commit() error RollBack() error Prepare(interface{}) (TxWorldState, error) Reset(addr byteutils.Hash, isResetChangeLog bool) error Flush() error Abort() error LoadAccountsRoot(byteutils.Hash) error LoadTxsRoot(byteutils.Hash) error LoadEventsRoot(byteutils.Hash) error LoadConsensusRoot(*consensuspb.ConsensusRoot) error NextConsensusState(int64) (ConsensusState, error) SetConsensusState(ConsensusState) Clone() (WorldState, error) AccountsRoot() byteutils.Hash TxsRoot() byteutils.Hash EventsRoot() byteutils.Hash ConsensusRoot() *consensuspb.ConsensusRoot Accounts() ([]Account, error) GetOrCreateUserAccount(addr byteutils.Hash) (Account, error) GetContractAccount(addr byteutils.Hash) (Account, error) CreateContractAccount(owner byteutils.Hash, birthPlace byteutils.Hash, contractMeta *corepb.ContractMeta) (Account, error) GetTx(txHash byteutils.Hash) ([]byte, error) PutTx(txHash byteutils.Hash, txBytes []byte) error RecordEvent(txHash byteutils.Hash, event *Event) FetchEvents(byteutils.Hash) ([]*Event, error) Dynasty() ([]byteutils.Hash, error) DynastyRoot() byteutils.Hash RecordGas(from string, gas *util.Uint128) error GetGas() map[string]*util.Uint128 GetBlockHashByHeight(height uint64) ([]byte, error) GetBlock(txHash byteutils.Hash) ([]byte, error) }
WorldState interface of world state
func NewWorldState ¶
func NewWorldState(consensus Consensus, storage storage.Storage) (WorldState, error)
NewWorldState create a new empty WorldState
Click to show internal directories.
Click to hide internal directories.