Contract call handling
How Applayer's BDK handles chains of contract execution.
ContractStack class overview
class ContractStack {
private:
boost::unordered_flat_map<Address, Bytes, SafeHash> code_;
boost::unordered_flat_map<Address, uint256_t, SafeHash> balance_;
boost::unordered_flat_map<Address, uint64_t, SafeHash> nonce_;
boost::unordered_flat_map<StorageKey, Hash, SafeHash> storage_;
std::vector<Event> events_;
std::vector<std::pair<Address,BaseContract*>> contracts_;
std::vector<std::reference_wrapper<SafeBase>> usedVars_;
public:
inline void registerCode(const Address& addr, const Bytes& code) { this->code_.try_emplace(addr, code); }
inline void registerBalance(const Address& addr, const uint256_t& balance) { this->balance_.try_emplace(addr, balance); }
inline void registerNonce(const Address& addr, const uint64_t& nonce) { this->nonce_.try_emplace(addr, nonce); }
inline void registerStorageChange(const StorageKey& key, const Hash& value) { this->storage_.try_emplace(key, value); }
inline void registerEvent(Event event) { this->events_.emplace_back(std::move(event)); }
inline void registerContract(const Address& addr, BaseContract* contract) { this->contracts_.emplace_back(addr, contract); }
inline void registerVariableUse(SafeBase& var) { this->usedVars_.emplace_back(var); }
inline const boost::unordered_flat_map<Address, Bytes, SafeHash>& getCode() const { return this->code_; }
inline const boost::unordered_flat_map<Address, uint256_t, SafeHash>& getBalance() const { return this->balance_; }
inline const boost::unordered_flat_map<Address, uint64_t, SafeHash>& getNonce() const { return this->nonce_; }
inline const boost::unordered_flat_map<StorageKey, Hash, SafeHash>& getStorage() const { return this->storage_; }
inline std::vector<Event>& getEvents() { return this->events_; }
inline const std::vector<std::pair<Address,BaseContract*>>& getContracts() const { return this->contracts_; }
inline const std::vector<std::reference_wrapper<SafeBase>>& getUsedVars() const { return this->usedVars_; }
};Last updated