Documentation
¶
Index ¶
- func AccountAddress(i *big.Int) []byte
- type Account
- type AccountMap
- type BlockchainHookMock
- func (b *BlockchainHookMock) AccountExists(address []byte) (bool, error)
- func (b *BlockchainHookMock) Clear()
- func (b *BlockchainHookMock) GetBalance(address []byte) (*big.Int, error)
- func (b *BlockchainHookMock) GetBlockhash(offset *big.Int) ([]byte, error)
- func (b *BlockchainHookMock) GetCode(address []byte) ([]byte, error)
- func (b *BlockchainHookMock) GetNonce(address []byte) (uint64, error)
- func (b *BlockchainHookMock) GetStorageData(accountAddress []byte, index []byte) ([]byte, error)
- func (b *BlockchainHookMock) IsCodeEmpty(address []byte) (bool, error)
- func (b *BlockchainHookMock) NewAddress(creatorAddress []byte, creatorNonce uint64) ([]byte, error)
- func (b *BlockchainHookMock) UpdateAccounts(modifiedAccounts []*vmi.OutputAccount, accountsToDelete [][]byte) error
- func (b *BlockchainHookMock) UpdateBalance(address []byte, newBalance *big.Int) error
- func (b *BlockchainHookMock) UpdateWorldStateBefore(fromAddr []byte, gasLimit *big.Int, gasPrice *big.Int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountAddress ¶
AccountAddress converts to account address bytes from big.Int
Types ¶
type Account ¶
type Account struct {
Exists bool
Address []byte
Nonce uint64
Balance *big.Int
BalanceDelta *big.Int
Storage map[string][]byte
Code []byte
}
Account holds the account info
func (*Account) StorageValue ¶
StorageValue yields the storage value for key, default 0
type AccountMap ¶
AccountMap is a map from address to account
func NewAccountMap ¶
func NewAccountMap() AccountMap
NewAccountMap creates a new AccountMap instance
func (AccountMap) DeleteAccount ¶
func (am AccountMap) DeleteAccount(address []byte)
DeleteAccount removes account based on address
func (AccountMap) GetAccount ¶
func (am AccountMap) GetAccount(address []byte) *Account
GetAccount retrieves account based on address
func (AccountMap) PutAccount ¶
func (am AccountMap) PutAccount(acct *Account)
PutAccount inserts account based on address
type BlockchainHookMock ¶
type BlockchainHookMock struct {
AcctMap AccountMap
Blockhashes [][]byte
}
BlockchainHookMock
func NewMock ¶
func NewMock() *BlockchainHookMock
func (*BlockchainHookMock) AccountExists ¶
func (b *BlockchainHookMock) AccountExists(address []byte) (bool, error)
AccountExists note: an account with Balance = 0 and Nonce = 0 is considered to not exist
func (*BlockchainHookMock) Clear ¶
func (b *BlockchainHookMock) Clear()
func (*BlockchainHookMock) GetBalance ¶
func (b *BlockchainHookMock) GetBalance(address []byte) (*big.Int, error)
GetBalance should retrieve the balance of an account
func (*BlockchainHookMock) GetBlockhash ¶
func (b *BlockchainHookMock) GetBlockhash(offset *big.Int) ([]byte, error)
GetBlockhash should return the hash of the nth previous blockchain. Offset specifies how many blocks we need to look back.
func (*BlockchainHookMock) GetCode ¶
func (b *BlockchainHookMock) GetCode(address []byte) ([]byte, error)
GetCode should return the compiled and assembled SC code. Empty byte array if the account is a wallet.
func (*BlockchainHookMock) GetNonce ¶
func (b *BlockchainHookMock) GetNonce(address []byte) (uint64, error)
GetNonce should retrieve the nonce of an account
func (*BlockchainHookMock) GetStorageData ¶
func (b *BlockchainHookMock) GetStorageData(accountAddress []byte, index []byte) ([]byte, error)
GetStorageData yields the storage value for a certain account and index. Should return an empty byte array if the key is missing from the account storage
func (*BlockchainHookMock) IsCodeEmpty ¶
func (b *BlockchainHookMock) IsCodeEmpty(address []byte) (bool, error)
IsCodeEmpty should return whether of not an account is SC.
func (*BlockchainHookMock) NewAddress ¶ added in v0.0.16
func (b *BlockchainHookMock) NewAddress(creatorAddress []byte, creatorNonce uint64) ([]byte, error)
NewAddress adapts between K model and elrond function
func (*BlockchainHookMock) UpdateAccounts ¶
func (b *BlockchainHookMock) UpdateAccounts(modifiedAccounts []*vmi.OutputAccount, accountsToDelete [][]byte) error
UpdateAccounts should be called after the VM test has run, to update world state
func (*BlockchainHookMock) UpdateBalance ¶
func (b *BlockchainHookMock) UpdateBalance(address []byte, newBalance *big.Int) error
UpdateBalance changes balance of an account
func (*BlockchainHookMock) UpdateWorldStateBefore ¶
func (b *BlockchainHookMock) UpdateWorldStateBefore( fromAddr []byte, gasLimit *big.Int, gasPrice *big.Int) error
UpdateWorldStateBefore performs gas payment, before transaction