hooks

package
v1.0.56 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAddressLengthNotCorrect = errors.New("address length is not correct")

ErrAddressLengthNotCorrect signals that an account does not have the correct address

View Source
var ErrEmptyCode = errors.New("empty code in provided smart contract holding account")

ErrEmptyCode signals that an account does not contain code

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented signals that a functionality can not be used as it is not implemented

View Source
var ErrVMTypeLengthIsNotCorrect = errors.New("vm type length is not correct")

ErrVMTypeLengthIsNotCorrect signals that the vm type length is not correct

Functions

This section is empty.

Types

type ArgBlockChainHook

type ArgBlockChainHook struct {
	Accounts         state.AccountsAdapter
	AddrConv         state.AddressConverter
	StorageService   dataRetriever.StorageService
	BlockChain       data.ChainHandler
	ShardCoordinator sharding.Coordinator
	Marshalizer      marshal.Marshalizer
	Uint64Converter  typeConverters.Uint64ByteSliceConverter
}

ArgBlockChainHook represents the arguments structure for the blockchain hook

type BlockChainHookImpl

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

BlockChainHookImpl is a wrapper over AccountsAdapter that satisfy vmcommon.BlockchainHook interface

func NewBlockChainHookImpl

func NewBlockChainHookImpl(
	args ArgBlockChainHook,
) (*BlockChainHookImpl, error)

NewBlockChainHookImpl creates a new BlockChainHookImpl instance

func (*BlockChainHookImpl) AccountExists

func (bh *BlockChainHookImpl) AccountExists(address []byte) (bool, error)

AccountExists checks if an account exists in provided AccountAdapter

func (*BlockChainHookImpl) AddTempAccount

func (bh *BlockChainHookImpl) AddTempAccount(address []byte, balance *big.Int, nonce uint64)

AddTempAccount will add a temporary account in temporary store

func (*BlockChainHookImpl) CleanTempAccounts

func (bh *BlockChainHookImpl) CleanTempAccounts()

CleanTempAccounts cleans the map holding the temporary accounts

func (*BlockChainHookImpl) CurrentEpoch

func (bh *BlockChainHookImpl) CurrentEpoch() uint32

CurrentEpoch returns the current epoch

func (*BlockChainHookImpl) CurrentNonce

func (bh *BlockChainHookImpl) CurrentNonce() uint64

CurrentNonce returns the nonce from the current block

func (*BlockChainHookImpl) CurrentRandomSeed

func (bh *BlockChainHookImpl) CurrentRandomSeed() []byte

CurrentRandomSeed returns the random seed from the current header

func (*BlockChainHookImpl) CurrentRound

func (bh *BlockChainHookImpl) CurrentRound() uint64

CurrentRound returns the round from the current block

func (*BlockChainHookImpl) CurrentTimeStamp

func (bh *BlockChainHookImpl) CurrentTimeStamp() uint64

CurrentTimeStamp return the timestamp from the current block

func (*BlockChainHookImpl) GetBalance

func (bh *BlockChainHookImpl) GetBalance(address []byte) (*big.Int, error)

GetBalance returns the balance of a shard account

func (*BlockChainHookImpl) GetBlockhash

func (bh *BlockChainHookImpl) GetBlockhash(nonce uint64) ([]byte, error)

GetBlockhash returns the header hash for a requested nonce delta

func (*BlockChainHookImpl) GetCode

func (bh *BlockChainHookImpl) GetCode(address []byte) ([]byte, error)

GetCode retrieves the account's code

func (*BlockChainHookImpl) GetNonce

func (bh *BlockChainHookImpl) GetNonce(address []byte) (uint64, error)

GetNonce returns the nonce of a shard account

func (*BlockChainHookImpl) GetStateRootHash

func (bh *BlockChainHookImpl) GetStateRootHash() []byte

GetStateRootHash returns the state root hash from the last committed block

func (*BlockChainHookImpl) GetStorageData

func (bh *BlockChainHookImpl) GetStorageData(accountAddress []byte, index []byte) ([]byte, error)

GetStorageData returns the storage value of a variable held in account's data trie

func (*BlockChainHookImpl) IsCodeEmpty

func (bh *BlockChainHookImpl) IsCodeEmpty(address []byte) (bool, error)

IsCodeEmpty returns if the code is empty

func (*BlockChainHookImpl) IsInterfaceNil

func (bh *BlockChainHookImpl) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*BlockChainHookImpl) LastEpoch

func (bh *BlockChainHookImpl) LastEpoch() uint32

LastEpoch returns the epoch from the last committed block

func (*BlockChainHookImpl) LastNonce

func (bh *BlockChainHookImpl) LastNonce() uint64

LastNonce returns the nonce from from the last committed block

func (*BlockChainHookImpl) LastRandomSeed

func (bh *BlockChainHookImpl) LastRandomSeed() []byte

LastRandomSeed returns the random seed from the last committed block

func (*BlockChainHookImpl) LastRound

func (bh *BlockChainHookImpl) LastRound() uint64

LastRound returns the round from the last committed block

func (*BlockChainHookImpl) LastTimeStamp

func (bh *BlockChainHookImpl) LastTimeStamp() uint64

LastTimeStamp returns the timeStamp from the last committed block

func (*BlockChainHookImpl) NewAddress

func (bh *BlockChainHookImpl) NewAddress(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error)

NewAddress is a hook which creates a new smart contract address from the creators address and nonce The address is created by applied keccak256 on the appended value off creator address and nonce Prefix mask is applied for first 8 bytes 0, and for bytes 9-10 - VM type Suffix mask is applied - last 2 bytes are for the shard ID - mask is applied as suffix mask

func (*BlockChainHookImpl) SetCurrentHeader

func (bh *BlockChainHookImpl) SetCurrentHeader(hdr data.HeaderHandler)

SetCurrentHeader sets current header to be used by smart contracts

func (*BlockChainHookImpl) TempAccount

func (bh *BlockChainHookImpl) TempAccount(address []byte) state.AccountHandler

TempAccount can retrieve a temporary account from provided address

type TempAccountTracker added in v1.0.39

type TempAccountTracker struct {
}

func (*TempAccountTracker) IsInterfaceNil added in v1.0.39

func (t *TempAccountTracker) IsInterfaceNil() bool

func (*TempAccountTracker) Journalize added in v1.0.39

func (t *TempAccountTracker) Journalize(entry state.JournalEntry)

func (*TempAccountTracker) SaveAccount added in v1.0.39

func (t *TempAccountTracker) SaveAccount(accountHandler state.AccountHandler) error

type VMCryptoHook

type VMCryptoHook struct {
}

VMCryptoHook is a wrapper used in vm implementation

func NewVMCryptoHook

func NewVMCryptoHook() *VMCryptoHook

NewVMCryptoHook creates a new instance of a vm crypto hook

func (*VMCryptoHook) Ecrecover

func (vmch *VMCryptoHook) Ecrecover(hash []byte, recoveryID []byte, r []byte, s []byte) ([]byte, error)

Ecrecover calculates the corresponding Ethereum address for the public key which created the given signature https://ewasm.readthedocs.io/en/mkdocs/system_contracts/

func (*VMCryptoHook) Keccak256

func (vmch *VMCryptoHook) Keccak256(data []byte) ([]byte, error)

Keccak256 returns a keccak 256 hash of the input string. Should return in hex format.

func (*VMCryptoHook) Ripemd160

func (vmch *VMCryptoHook) Ripemd160(data []byte) ([]byte, error)

Ripemd160 is a legacy hash and should not be used for new applications

func (*VMCryptoHook) Sha256

func (vmch *VMCryptoHook) Sha256(data []byte) ([]byte, error)

Sha256 returns a sha 256 hash of the input string. Should return in hex format.

Jump to

Keyboard shortcuts

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