Documentation ¶
Index ¶
- Constants
- Variables
- func NewAddress(adr []byte) *address
- type Account
- func (a *Account) AddressContainer() AddressContainer
- func (a *Account) DataTrie() data.Trie
- func (a *Account) DataTrieTracker() DataTrieTracker
- func (a *Account) GetCode() []byte
- func (a *Account) GetCodeHash() []byte
- func (a *Account) GetNonce() uint64
- func (a *Account) GetRootHash() []byte
- func (a *Account) IsInterfaceNil() bool
- func (a *Account) SetBalanceWithJournal(balance *big.Int) error
- func (a *Account) SetCode(code []byte)
- func (a *Account) SetCodeHash(codeHash []byte)
- func (a *Account) SetCodeHashWithJournal(codeHash []byte) error
- func (a *Account) SetDataTrie(trie data.Trie)
- func (a *Account) SetNonce(nonce uint64)
- func (a *Account) SetNonceWithJournal(nonce uint64) error
- func (a *Account) SetRootHash(roothash []byte)
- func (a *Account) SetRootHashWithJournal(rootHash []byte) error
- type AccountFactory
- type AccountHandler
- type AccountTracker
- type AccountsAdapter
- type AccountsDB
- func (adb *AccountsDB) Commit() ([]byte, error)
- func (adb *AccountsDB) GetAccountWithJournal(addressContainer AddressContainer) (AccountHandler, error)
- func (adb *AccountsDB) GetExistingAccount(addressContainer AddressContainer) (AccountHandler, error)
- func (adb *AccountsDB) HasAccount(addressContainer AddressContainer) (bool, error)
- func (adb *AccountsDB) JournalLen() int
- func (adb *AccountsDB) Journalize(entry JournalEntry)
- func (adb *AccountsDB) PutCode(accountHandler AccountHandler, code []byte) error
- func (adb *AccountsDB) RecreateTrie(rootHash []byte) error
- func (adb *AccountsDB) RemoveAccount(addressContainer AddressContainer) error
- func (adb *AccountsDB) RemoveCode(codeHash []byte) error
- func (adb *AccountsDB) RevertToSnapshot(snapshot int) error
- func (adb *AccountsDB) RootHash() ([]byte, error)
- func (adb *AccountsDB) SaveAccount(accountHandler AccountHandler) error
- func (adb *AccountsDB) SaveDataTrie(accountHandler AccountHandler) error
- type AddressContainer
- type AddressConverter
- type BaseJournalEntryCodeHash
- type BaseJournalEntryCreation
- type BaseJournalEntryData
- type BaseJournalEntryNonce
- type BaseJournalEntryRootHash
- type DataTrieTracker
- type ErrMissingTrie
- type ErrorTrieNotNormalized
- type ErrorWrongSize
- type JournalEntry
- type JournalEntryBalance
- type MetaAccount
- func (a *MetaAccount) AddressContainer() AddressContainer
- func (a *MetaAccount) DataTrie() data.Trie
- func (a *MetaAccount) DataTrieTracker() DataTrieTracker
- func (a *MetaAccount) GetCode() []byte
- func (a *MetaAccount) GetCodeHash() []byte
- func (a *MetaAccount) GetNonce() uint64
- func (a *MetaAccount) GetRootHash() []byte
- func (a *MetaAccount) IsInterfaceNil() bool
- func (a *MetaAccount) SetCode(code []byte)
- func (a *MetaAccount) SetCodeHash(roothash []byte)
- func (a *MetaAccount) SetCodeHashWithJournal(codeHash []byte) error
- func (a *MetaAccount) SetDataTrie(trie data.Trie)
- func (a *MetaAccount) SetMiniBlocksDataWithJournal(miniBlocksData []*MiniBlockData) error
- func (a *MetaAccount) SetNonce(nonce uint64)
- func (a *MetaAccount) SetNonceWithJournal(nonce uint64) error
- func (a *MetaAccount) SetRootHash(roothash []byte)
- func (a *MetaAccount) SetRootHashWithJournal(rootHash []byte) error
- func (a *MetaAccount) SetRoundWithJournal(round uint64) error
- func (a *MetaAccount) SetShardRootHashWithJournal(shardRootHash []byte) error
- func (a *MetaAccount) SetTxCountWithJournal(txCount *big.Int) error
- type MetaJournalEntryMiniBlocksData
- type MetaJournalEntryRound
- type MetaJournalEntryShardRootHash
- type MetaJournalEntryTxCount
- type MiniBlockData
- type TrackableDataTrie
- func (tdaw *TrackableDataTrie) ClearDataCaches()
- func (tdaw *TrackableDataTrie) DataTrie() data.Trie
- func (tdaw *TrackableDataTrie) DirtyData() map[string][]byte
- func (tdaw *TrackableDataTrie) OriginalValue(key []byte) []byte
- func (tdaw *TrackableDataTrie) RetrieveValue(key []byte) ([]byte, error)
- func (tdaw *TrackableDataTrie) SaveKeyValue(key []byte, value []byte)
- func (tdaw *TrackableDataTrie) SetDataTrie(tr data.Trie)
- type Updater
Constants ¶
const HashLength = 32
HashLength defines how many bytes are used in a hash
Variables ¶
var ErrAccNotFound = errors.New("account was not found")
ErrAccNotFound signals that account was not found in state trie
var ErrBech32ConvertError = errors.New("can't convert bech32 string")
ErrBech32ConvertError signals that conversion the 5bit alphabet to 8bit failed
var ErrBech32WrongAddr = errors.New("wrong bech32 string")
ErrBech32WrongAddr signals that the string provided might not be in bech32 format
var ErrEmptyAddress = errors.New("empty Address")
ErrEmptyAddress defines the error when trying to work with an empty address
var ErrNegativeValue = errors.New("negative values are not permited")
ErrNegativeValue signals that an operation has been attempted with a negative value
var ErrNilAccountFactory = errors.New("account factory is nil")
ErrNilAccountFactory signals that a nil account factory was provided
var ErrNilAccountHandler = errors.New("account wrapper is nil")
ErrNilAccountHandler signals that a nil account wrapper was provided
var ErrNilAccountTracker = errors.New("nil account tracker provided")
ErrNilAccountTracker signals that a nil account tracker has been provided
var ErrNilAccountsAdapter = errors.New("nil AccountsAdapter")
ErrNilAccountsAdapter defines the error when trying to revert on nil accounts
var ErrNilAddressContainer = errors.New("nil AddressContainer")
ErrNilAddressContainer defines the error when trying to work with a nil address
var ErrNilAddressConverter = errors.New("nil address converter")
ErrNilAddressConverter signals that a nil address converter has been provided
var ErrNilCode = errors.New("nil smart contract code")
ErrNilCode signals that a nil code was provided
var ErrNilHasher = errors.New("nil hasher")
ErrNilHasher signals that an operation has been attempted to or with a nil hasher implementation
var ErrNilMarshalizer = errors.New("nil marshalizer")
ErrNilMarshalizer signals that an operation has been attempted to or with a nil marshalizer implementation
var ErrNilOrEmptyKey = errors.New("key is empty or nil")
ErrNilOrEmptyKey signals that key empty key was provided
var ErrNilPubKeysBytes = errors.New("nil public key bytes")
ErrNilPubKeysBytes signals that an operation has been attempted to or with a nil public key slice
var ErrNilShardCoordinator = errors.New("shard coordinator is nil")
ErrNilShardCoordinator signals that nil shard coordinator was provided
var ErrNilTrackableDataTrie = errors.New("nil trackable data trie")
ErrNilTrackableDataTrie signals that a nil trackable data trie has been provided
var ErrNilTrie = errors.New("trie is nil")
ErrNilTrie signals that a trie is nil and no operation can be made
var ErrNilUpdater = errors.New("updater is nil")
ErrNilUpdater signals that a nil updater has been provided
var ErrNilValue = errors.New("nil value")
ErrNilValue signals that an operation has been attempted to or with a nil value
var ErrUnknownShardId = errors.New("shard id is not valid")
ErrUnknownShardId signals that shard id is not valid
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
ErrWrongTypeAssertion signals that a wrong type assertion occurred
Functions ¶
func NewAddress ¶
func NewAddress(adr []byte) *address
NewAddress creates a new Address with the same byte slice as the parameter received
Types ¶
type Account ¶ added in v1.0.3
type Account struct { Nonce uint64 Balance *big.Int CodeHash []byte RootHash []byte // contains filtered or unexported fields }
Account is the struct used in serialization/deserialization
func NewAccount ¶ added in v1.0.3
func NewAccount(addressContainer AddressContainer, tracker AccountTracker) (*Account, error)
NewAccount creates new simple account wrapper for an AccountContainer (that has just been initialized)
func (*Account) AddressContainer ¶ added in v1.0.3
func (a *Account) AddressContainer() AddressContainer
AddressContainer returns the address associated with the account
func (*Account) DataTrie ¶ added in v1.0.3
DataTrie returns the trie that holds the current account's data
func (*Account) DataTrieTracker ¶ added in v1.0.3
func (a *Account) DataTrieTracker() DataTrieTracker
DataTrieTracker returns the trie wrapper used in managing the SC data
func (*Account) GetCode ¶ added in v1.0.3
GetCode gets the actual code that needs to be run in the VM
func (*Account) GetCodeHash ¶ added in v1.0.3
GetCodeHash returns the code hash associated with this account
func (*Account) GetRootHash ¶ added in v1.0.3
GetRootHash returns the root hash associated with this account
func (*Account) IsInterfaceNil ¶ added in v1.0.3
IsInterfaceNil return if there is no value under the interface
func (*Account) SetBalanceWithJournal ¶ added in v1.0.3
SetBalanceWithJournal sets the account's balance, saving the old balance before changing
func (*Account) SetCode ¶ added in v1.0.3
SetCode sets the actual code that needs to be run in the VM
func (*Account) SetCodeHash ¶ added in v1.0.3
SetCodeHash sets the code hash associated with the account
func (*Account) SetCodeHashWithJournal ¶ added in v1.0.3
SetCodeHashWithJournal sets the account's code hash, saving the old code hash before changing
func (*Account) SetDataTrie ¶ added in v1.0.3
SetDataTrie sets the trie that holds the current account's data
func (*Account) SetNonceWithJournal ¶ added in v1.0.3
SetNonceWithJournal sets the account's nonce, saving the old nonce before changing
func (*Account) SetRootHash ¶ added in v1.0.3
SetRootHash sets the root hash associated with the account
func (*Account) SetRootHashWithJournal ¶ added in v1.0.3
SetRootHashWithJournal sets the account's root hash, saving the old root hash before changing
type AccountFactory ¶
type AccountFactory interface {
CreateAccount(address AddressContainer, tracker AccountTracker) (AccountHandler, error)
}
AccountFactory creates an account of different types
type AccountHandler ¶
type AccountHandler interface { AddressContainer() AddressContainer GetCodeHash() []byte SetCodeHash([]byte) SetCodeHashWithJournal([]byte) error GetCode() []byte SetCode(code []byte) SetNonce(nonce uint64) GetNonce() uint64 SetNonceWithJournal(nonce uint64) error GetRootHash() []byte SetRootHash([]byte) SetRootHashWithJournal([]byte) error DataTrie() data.Trie SetDataTrie(trie data.Trie) DataTrieTracker() DataTrieTracker IsInterfaceNil() bool }
AccountHandler models a state account, which can journalize and revert It knows about code and data, as data structures not hashes
type AccountTracker ¶ added in v1.0.3
type AccountTracker interface { SaveAccount(accountHandler AccountHandler) error Journalize(entry JournalEntry) }
AccountTracker saves an account state and journalizes new entries
type AccountsAdapter ¶
type AccountsAdapter interface { GetAccountWithJournal(addressContainer AddressContainer) (AccountHandler, error) // will create if it not exist GetExistingAccount(addressContainer AddressContainer) (AccountHandler, error) HasAccount(addressContainer AddressContainer) (bool, error) RemoveAccount(addressContainer AddressContainer) error Commit() ([]byte, error) JournalLen() int RevertToSnapshot(snapshot int) error RootHash() ([]byte, error) RecreateTrie(rootHash []byte) error PutCode(accountHandler AccountHandler, code []byte) error RemoveCode(codeHash []byte) error SaveDataTrie(accountHandler AccountHandler) error }
AccountsAdapter is used for the structure that manages the accounts on top of a trie.PatriciaMerkleTrie implementation
type AccountsDB ¶
type AccountsDB struct {
// contains filtered or unexported fields
}
AccountsDB is the struct used for accessing accounts
func NewAccountsDB ¶
func NewAccountsDB( trie data.Trie, hasher hashing.Hasher, marshalizer marshal.Marshalizer, accountFactory AccountFactory, ) (*AccountsDB, error)
NewAccountsDB creates a new account manager
func (*AccountsDB) Commit ¶
func (adb *AccountsDB) Commit() ([]byte, error)
Commit will persist all data inside the trie
func (*AccountsDB) GetAccountWithJournal ¶ added in v1.0.3
func (adb *AccountsDB) GetAccountWithJournal(addressContainer AddressContainer) (AccountHandler, error)
GetAccountWithJournal fetches the account based on the address. Creates an empty account if the account is missing.
func (*AccountsDB) GetExistingAccount ¶
func (adb *AccountsDB) GetExistingAccount(addressContainer AddressContainer) (AccountHandler, error)
GetExistingAccount returns an existing account if exists or nil if missing
func (*AccountsDB) HasAccount ¶ added in v1.0.3
func (adb *AccountsDB) HasAccount(addressContainer AddressContainer) (bool, error)
HasAccount searches for an account based on the address. Errors if something went wrong and outputs if the account exists or not
func (*AccountsDB) JournalLen ¶
func (adb *AccountsDB) JournalLen() int
JournalLen will return the number of entries Concurrent safe.
func (*AccountsDB) Journalize ¶ added in v1.0.3
func (adb *AccountsDB) Journalize(entry JournalEntry)
Journalize adds a new object to entries list. Concurrent safe.
func (*AccountsDB) PutCode ¶ added in v1.0.3
func (adb *AccountsDB) PutCode(accountHandler AccountHandler, code []byte) error
PutCode sets the SC plain code in AccountHandler object and trie, code hash in AccountState. Errors if something went wrong
func (*AccountsDB) RecreateTrie ¶
func (adb *AccountsDB) RecreateTrie(rootHash []byte) error
RecreateTrie is used to reload the trie based on an existing rootHash
func (*AccountsDB) RemoveAccount ¶
func (adb *AccountsDB) RemoveAccount(addressContainer AddressContainer) error
RemoveAccount removes the account data from underlying trie. It basically calls Update with empty slice
func (*AccountsDB) RemoveCode ¶ added in v1.0.3
func (adb *AccountsDB) RemoveCode(codeHash []byte) error
RemoveCode deletes the code from the trie. It writes an empty byte slice at codeHash "address"
func (*AccountsDB) RevertToSnapshot ¶
func (adb *AccountsDB) RevertToSnapshot(snapshot int) error
RevertToSnapshot apply Revert method over accounts object and removes entries from the list If snapshot > len(entries) will do nothing, return will be nil 0 index based. Calling this method with negative value will do nothing. Calling with 0 revert everything. Concurrent safe.
func (*AccountsDB) RootHash ¶
func (adb *AccountsDB) RootHash() ([]byte, error)
RootHash returns the main trie's root hash
func (*AccountsDB) SaveAccount ¶
func (adb *AccountsDB) SaveAccount(accountHandler AccountHandler) error
SaveAccount saves the account WITHOUT data trie inside main trie. Errors if something went wrong
func (*AccountsDB) SaveDataTrie ¶ added in v1.0.3
func (adb *AccountsDB) SaveDataTrie(accountHandler AccountHandler) error
SaveDataTrie is used to save the data trie (not committing it) and to recompute the new Root value If data is not dirtied, method will not create its JournalEntries to keep track of data modification
type AddressContainer ¶
type AddressContainer interface {
Bytes() []byte
}
AddressContainer models what an Address struct should do
type AddressConverter ¶
type AddressConverter interface { AddressLen() int CreateAddressFromPublicKeyBytes(pubKey []byte) (AddressContainer, error) ConvertToHex(addressContainer AddressContainer) (string, error) CreateAddressFromHex(hexAddress string) (AddressContainer, error) PrepareAddressBytes(addressBytes []byte) ([]byte, error) }
AddressConverter is used to convert to/from AddressContainer
type BaseJournalEntryCodeHash ¶ added in v1.0.3
type BaseJournalEntryCodeHash struct {
// contains filtered or unexported fields
}
BaseJournalEntryCodeHash creates a code hash change in account
func NewBaseJournalEntryCodeHash ¶ added in v1.0.3
func NewBaseJournalEntryCodeHash(account AccountHandler, oldCodeHash []byte) (*BaseJournalEntryCodeHash, error)
NewBaseJournalEntryCodeHash outputs a new BaseJournalEntry implementation used to save and revert a code hash change
func (*BaseJournalEntryCodeHash) Revert ¶ added in v1.0.3
func (bjech *BaseJournalEntryCodeHash) Revert() (AccountHandler, error)
Revert applies undo operation
type BaseJournalEntryCreation ¶ added in v1.0.3
type BaseJournalEntryCreation struct {
// contains filtered or unexported fields
}
BaseJournalEntryCreation creates a new account entry in the state trie through updater it can revert the created changes.
func NewBaseJournalEntryCreation ¶ added in v1.0.3
func NewBaseJournalEntryCreation(key []byte, updater Updater) (*BaseJournalEntryCreation, error)
NewBaseJournalEntryCreation outputs a new BaseJournalEntry implementation used to revert an account creation
func (*BaseJournalEntryCreation) Revert ¶ added in v1.0.3
func (bjec *BaseJournalEntryCreation) Revert() (AccountHandler, error)
Revert applies undo operation
type BaseJournalEntryData ¶ added in v1.0.3
type BaseJournalEntryData struct {
// contains filtered or unexported fields
}
BaseJournalEntryData is used to mark an account's data change
func NewBaseJournalEntryData ¶ added in v1.0.3
func NewBaseJournalEntryData(account AccountHandler, trie data.Trie) (*BaseJournalEntryData, error)
NewBaseJournalEntryData outputs a new BaseJournalEntry implementation used to keep track of data change. The revert will practically empty the dirty data map
func (*BaseJournalEntryData) Revert ¶ added in v1.0.3
func (bjed *BaseJournalEntryData) Revert() (AccountHandler, error)
Revert will empty the dirtyData map from AccountState
func (*BaseJournalEntryData) Trie ¶ added in v1.0.3
func (bjed *BaseJournalEntryData) Trie() data.Trie
Trie returns the referenced PatriciaMerkelTree for committing the changes
type BaseJournalEntryNonce ¶ added in v1.0.11
type BaseJournalEntryNonce struct {
// contains filtered or unexported fields
}
BaseJournalEntryNonce is used to revert a nonce change
func NewBaseJournalEntryNonce ¶ added in v1.0.11
func NewBaseJournalEntryNonce(account AccountHandler, oldNonce uint64) (*BaseJournalEntryNonce, error)
NewBaseJournalEntryNonce outputs a new JournalEntry implementation used to revert a nonce change
func (*BaseJournalEntryNonce) Revert ¶ added in v1.0.11
func (bjen *BaseJournalEntryNonce) Revert() (AccountHandler, error)
Revert applies undo operation
type BaseJournalEntryRootHash ¶ added in v1.0.3
type BaseJournalEntryRootHash struct {
// contains filtered or unexported fields
}
BaseJournalEntryRootHash creates an account's root hash change
func NewBaseJournalEntryRootHash ¶ added in v1.0.3
func NewBaseJournalEntryRootHash(account AccountHandler, oldRootHash []byte, oldTrie data.Trie) (*BaseJournalEntryRootHash, error)
NewBaseJournalEntryRootHash outputs a new BaseJournalEntry used to save and revert an account's root hash change
func (*BaseJournalEntryRootHash) Revert ¶ added in v1.0.3
func (bjer *BaseJournalEntryRootHash) Revert() (AccountHandler, error)
Revert applies undo operation
type DataTrieTracker ¶
type DataTrieTracker interface { ClearDataCaches() DirtyData() map[string][]byte OriginalValue(key []byte) []byte RetrieveValue(key []byte) ([]byte, error) SaveKeyValue(key []byte, value []byte) SetDataTrie(tr data.Trie) DataTrie() data.Trie }
DataTrieTracker models what how to manipulate data held by a SC account
type ErrMissingTrie ¶
type ErrMissingTrie struct {
// contains filtered or unexported fields
}
ErrMissingTrie is an error-compatible struct holding the root hash of the trie that is missing
func NewErrMissingTrie ¶
func NewErrMissingTrie(rootHash []byte) *ErrMissingTrie
NewErrMissingTrie returns a new instantiated struct
func (*ErrMissingTrie) Error ¶
func (e *ErrMissingTrie) Error() string
Error returns the error as string
type ErrorTrieNotNormalized ¶
type ErrorTrieNotNormalized struct {
// contains filtered or unexported fields
}
ErrorTrieNotNormalized is an error-compatible struct holding the hash length that is not normalized
func NewErrorTrieNotNormalized ¶
func NewErrorTrieNotNormalized(exp int, actual int) *ErrorTrieNotNormalized
NewErrorTrieNotNormalized returns a new instantiated struct
func (*ErrorTrieNotNormalized) Error ¶
func (e *ErrorTrieNotNormalized) Error() string
Error returns the error as string
type ErrorWrongSize ¶
ErrorWrongSize is an error-compatible struct holding 2 values: Expected and Got
func NewErrorWrongSize ¶
func NewErrorWrongSize(exp int, got int) *ErrorWrongSize
NewErrorWrongSize returns a new instantiated struct
func (*ErrorWrongSize) Error ¶
func (e *ErrorWrongSize) Error() string
Error returns the error as string
type JournalEntry ¶
type JournalEntry interface {
Revert() (AccountHandler, error)
}
JournalEntry will be used to implement different state changes to be able to easily revert them
type JournalEntryBalance ¶ added in v1.0.3
type JournalEntryBalance struct {
// contains filtered or unexported fields
}
JournalEntryBalance is used to revert a balance change
func NewJournalEntryBalance ¶ added in v1.0.3
func NewJournalEntryBalance(account *Account, oldBalance *big.Int) (*JournalEntryBalance, error)
NewJournalEntryBalance outputs a new JournalEntry implementation used to revert a balance change
func (*JournalEntryBalance) Revert ¶ added in v1.0.3
func (jeb *JournalEntryBalance) Revert() (AccountHandler, error)
Revert applies undo operation
type MetaAccount ¶ added in v1.0.3
type MetaAccount struct { Round uint64 Nonce uint64 TxCount *big.Int CodeHash []byte RootHash []byte MiniBlocks []*MiniBlockData PubKeyLeader []byte ShardRootHash []byte // contains filtered or unexported fields }
MetaAccount is the struct used in serialization/deserialization
func NewMetaAccount ¶ added in v1.0.3
func NewMetaAccount(addressContainer AddressContainer, tracker AccountTracker) (*MetaAccount, error)
NewMetaAccount creates new simple meta account for an AccountContainer (that has just been initialized)
func (*MetaAccount) AddressContainer ¶ added in v1.0.3
func (a *MetaAccount) AddressContainer() AddressContainer
AddressContainer returns the address associated with the account
func (*MetaAccount) DataTrie ¶ added in v1.0.3
func (a *MetaAccount) DataTrie() data.Trie
DataTrie returns the trie that holds the current account's data
func (*MetaAccount) DataTrieTracker ¶ added in v1.0.3
func (a *MetaAccount) DataTrieTracker() DataTrieTracker
DataTrieTracker returns the trie wrapper used in managing the SC data
func (*MetaAccount) GetCode ¶ added in v1.0.3
func (a *MetaAccount) GetCode() []byte
GetCode gets the actual code that needs to be run in the VM
func (*MetaAccount) GetCodeHash ¶ added in v1.0.3
func (a *MetaAccount) GetCodeHash() []byte
GetCodeHash returns the code hash associated with this account
func (*MetaAccount) GetNonce ¶ added in v1.0.3
func (a *MetaAccount) GetNonce() uint64
GetNonce gets the nonce of the account
func (*MetaAccount) GetRootHash ¶ added in v1.0.3
func (a *MetaAccount) GetRootHash() []byte
GetRootHash returns the root hash associated with this account
func (*MetaAccount) IsInterfaceNil ¶ added in v1.0.3
func (a *MetaAccount) IsInterfaceNil() bool
IsInterfaceNil return if there is no value under the interface
func (*MetaAccount) SetCode ¶ added in v1.0.3
func (a *MetaAccount) SetCode(code []byte)
SetCode sets the actual code that needs to be run in the VM
func (*MetaAccount) SetCodeHash ¶ added in v1.0.3
func (a *MetaAccount) SetCodeHash(roothash []byte)
SetCodeHash sets the code hash associated with the account
func (*MetaAccount) SetCodeHashWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetCodeHashWithJournal(codeHash []byte) error
SetCodeHashWithJournal sets the account's code hash, saving the old code hash before changing
func (*MetaAccount) SetDataTrie ¶ added in v1.0.3
func (a *MetaAccount) SetDataTrie(trie data.Trie)
SetDataTrie sets the trie that holds the current account's data
func (*MetaAccount) SetMiniBlocksDataWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetMiniBlocksDataWithJournal(miniBlocksData []*MiniBlockData) error
SetMiniBlocksDataWithJournal sets the current final mini blocks header data, saving the old mini blocks header data before changing
func (*MetaAccount) SetNonce ¶ added in v1.0.3
func (a *MetaAccount) SetNonce(nonce uint64)
SetNonce saves the nonce to the account
func (*MetaAccount) SetNonceWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetNonceWithJournal(nonce uint64) error
SetNonceWithJournal sets the account's nonce, saving the old nonce before changing
func (*MetaAccount) SetRootHash ¶ added in v1.0.3
func (a *MetaAccount) SetRootHash(roothash []byte)
SetRootHash sets the root hash associated with the account
func (*MetaAccount) SetRootHashWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetRootHashWithJournal(rootHash []byte) error
SetRootHashWithJournal sets the account's root hash, saving the old root hash before changing
func (*MetaAccount) SetRoundWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetRoundWithJournal(round uint64) error
SetRoundWithJournal sets the account's round, saving the old round before changing
func (*MetaAccount) SetShardRootHashWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetShardRootHashWithJournal(shardRootHash []byte) error
SetShardRootHashWithJournal sets the account's root hash, saving the old root hash before changing
func (*MetaAccount) SetTxCountWithJournal ¶ added in v1.0.3
func (a *MetaAccount) SetTxCountWithJournal(txCount *big.Int) error
SetTxCountWithJournal sets the total tx count for this shard, saving the old txCount before changing
type MetaJournalEntryMiniBlocksData ¶ added in v1.0.3
type MetaJournalEntryMiniBlocksData struct {
// contains filtered or unexported fields
}
MetaJournalEntryMiniBlocksData is used to revert a round change
func NewMetaJournalEntryMiniBlocksData ¶ added in v1.0.3
func NewMetaJournalEntryMiniBlocksData(account *MetaAccount, oldMiniBlocksData []*MiniBlockData) (*MetaJournalEntryMiniBlocksData, error)
NewMetaJournalEntryMiniBlocksData outputs a new JournalEntry implementation used to revert a MiniBlocksData change
func (*MetaJournalEntryMiniBlocksData) Revert ¶ added in v1.0.3
func (jen *MetaJournalEntryMiniBlocksData) Revert() (AccountHandler, error)
Revert applies undo operation
type MetaJournalEntryRound ¶ added in v1.0.3
type MetaJournalEntryRound struct {
// contains filtered or unexported fields
}
MetaJournalEntryRound is used to revert a round change
func NewMetaJournalEntryRound ¶ added in v1.0.3
func NewMetaJournalEntryRound(account *MetaAccount, oldRound uint64) (*MetaJournalEntryRound, error)
NewMetaJournalEntryRound outputs a new JournalEntry implementation used to revert a round change
func (*MetaJournalEntryRound) Revert ¶ added in v1.0.3
func (jen *MetaJournalEntryRound) Revert() (AccountHandler, error)
Revert applies undo operation
type MetaJournalEntryShardRootHash ¶ added in v1.0.3
type MetaJournalEntryShardRootHash struct {
// contains filtered or unexported fields
}
MetaJournalEntryShardRootHash is used to revert a round change
func NewMetaJournalEntryShardRootHash ¶ added in v1.0.3
func NewMetaJournalEntryShardRootHash(account *MetaAccount, oldShardRootHash []byte) (*MetaJournalEntryShardRootHash, error)
NewMetaJournalEntryShardRootHash outputs a new JournalEntry implementation used to revert a ShardRootHash change
func (*MetaJournalEntryShardRootHash) Revert ¶ added in v1.0.3
func (jen *MetaJournalEntryShardRootHash) Revert() (AccountHandler, error)
Revert applies undo operation
type MetaJournalEntryTxCount ¶ added in v1.0.3
type MetaJournalEntryTxCount struct {
// contains filtered or unexported fields
}
MetaJournalEntryTxCount is used to revert a round change
func NewMetaJournalEntryTxCount ¶ added in v1.0.3
func NewMetaJournalEntryTxCount(account *MetaAccount, oldTxCount *big.Int) (*MetaJournalEntryTxCount, error)
NewMetaJournalEntryTxCount outputs a new JournalEntry implementation used to revert a TxCount change
func (*MetaJournalEntryTxCount) Revert ¶ added in v1.0.3
func (jen *MetaJournalEntryTxCount) Revert() (AccountHandler, error)
Revert applies undo operation
type MiniBlockData ¶ added in v1.0.3
type MiniBlockData struct { Hash []byte ReceiverShardId uint32 SenderShardId uint32 TxCount uint32 }
MiniBlockData is the data to be saved in shard account for any shard
type TrackableDataTrie ¶
type TrackableDataTrie struct {
// contains filtered or unexported fields
}
TrackableDataTrie wraps a PatriciaMerkelTrie adding modifying data capabilities
func NewTrackableDataTrie ¶
func NewTrackableDataTrie(tr data.Trie) *TrackableDataTrie
NewTrackableDataTrie returns an instance of DataTrieTracker
func (*TrackableDataTrie) ClearDataCaches ¶
func (tdaw *TrackableDataTrie) ClearDataCaches()
ClearDataCaches empties the dirtyData map and original map
func (*TrackableDataTrie) DataTrie ¶
func (tdaw *TrackableDataTrie) DataTrie() data.Trie
DataTrie sets the internal data trie
func (*TrackableDataTrie) DirtyData ¶
func (tdaw *TrackableDataTrie) DirtyData() map[string][]byte
DirtyData returns the map of (key, value) pairs that contain the data needed to be saved in the data trie
func (*TrackableDataTrie) OriginalValue ¶
func (tdaw *TrackableDataTrie) OriginalValue(key []byte) []byte
OriginalValue returns the value for a key stored in originalData map which is acting like a cache
func (*TrackableDataTrie) RetrieveValue ¶
func (tdaw *TrackableDataTrie) RetrieveValue(key []byte) ([]byte, error)
RetrieveValue fetches the value from a particular key searching the account data store The search starts with dirty map, continues with original map and ends with the trie Data must have been retrieved from its trie
func (*TrackableDataTrie) SaveKeyValue ¶
func (tdaw *TrackableDataTrie) SaveKeyValue(key []byte, value []byte)
SaveKeyValue stores in dirtyData the data keys "touched" It does not care if the data is really dirty as calling this check here will be sub-optimal
func (*TrackableDataTrie) SetDataTrie ¶
func (tdaw *TrackableDataTrie) SetDataTrie(tr data.Trie)
SetDataTrie sets the internal data trie