Browse Source

Docs & consolidation of headers.

cl-refactor
Gav Wood 11 years ago
parent
commit
5aba1ea096
  1. 12
      libethcore/All.h
  2. 8
      libethential/All.h
  3. 14
      libethereum/All.h
  4. 31
      libethereum/Client.h
  5. 39
      libethereum/ExtVM.h
  6. 10
      libevm/ExtVMFace.h
  7. 7
      liblll/All.h
  8. 9
      libserpent/All.h

12
libethcore/All.h

@ -0,0 +1,12 @@
#pragma once
#include "BlockInfo.h"
#include "CommonEth.h"
#include "Dagger.h"
#include "FileSystem.h"
#include "MemoryDB.h"
#include "OverlayDB.h"
#include "SHA3.h"
#include "TrieCommon.h"
#include "TrieDB.h"
#include "UPnP.h"

8
libethential/All.h

@ -0,0 +1,8 @@
#pragma once
#include "Common.h"
#include "CommonData.h"
#include "CommonIO.h"
#include "FixedHash.h"
#include "Log.h"
#include "RLP.h"

14
libethereum/All.h

@ -0,0 +1,14 @@
#pragma once
#include "AddressState.h"
#include "BlockChain.h"
#include "Client.h"
#include "Defaults.h"
#include "Executive.h"
#include "ExtVM.h"
#include "PeerNetwork.h"
#include "PeerServer.h"
#include "PeerSession.h"
#include "State.h"
#include "Transaction.h"
#include "TransactionQueue.h"

31
libethereum/Client.h

@ -77,6 +77,9 @@ private:
unsigned m_protocolVersion; unsigned m_protocolVersion;
}; };
/**
* @brief Main API hub for interfacing with Ethereum.
*/
class Client class Client
{ {
public: public:
@ -114,24 +117,38 @@ public:
/// Calls @a _f when a transaction is mined that involves @a _dest and once per change. /// Calls @a _f when a transaction is mined that involves @a _dest and once per change.
// void onConfirmed(Address _dest, function<void(Transaction, AddressState)> const& _f); // void onConfirmed(Address _dest, function<void(Transaction, AddressState)> const& _f);
// Informational stuff: // Informational stuff
/// Locks/unlocks the state/blockChain/transactionQueue for access.
void lock();
void unlock();
/// Determines whether at least one of the state/blockChain/transactionQueue has changed since the last call to changed(). /// Determines whether at least one of the state/blockChain/transactionQueue has changed since the last call to changed().
bool changed() const { auto ret = m_changed; m_changed = false; return ret; } bool changed() const { auto ret = m_changed; m_changed = false; return ret; }
bool peekChanged() const { return m_changed; } bool peekChanged() const { return m_changed; }
/// Get a map containing each of the pending transactions.
Transactions pending() const { return m_postMine.pending(); }
// [OLD API]:
/// Locks/unlocks the state/blockChain/transactionQueue for access.
void lock();
void unlock();
/// Get the object representing the current state of Ethereum. /// Get the object representing the current state of Ethereum.
State const& state() const { return m_preMine; } State const& state() const { return m_preMine; }
/// Get the object representing the current state of Ethereum. /// Get the object representing the current state of Ethereum.
State const& postState() const { return m_postMine; } State const& postState() const { return m_postMine; }
/// Get the object representing the current canonical blockchain. /// Get the object representing the current canonical blockchain.
BlockChain const& blockChain() const { return m_bc; } BlockChain const& blockChain() const { return m_bc; }
/// Get a map containing each of the pending transactions.
Transactions pending() const { return m_postMine.pending(); } // [NEW API]
/*
u256 balanceAt(Address _a, unsigned _age = 1) const;
u256 countAt(Address _a, unsigned _age = 1) const;
u256 stateAt(Address _a, u256 _l, unsigned _age = 1) const;
bytes codeAt(Address _a, unsigned _age = 1) const;
Transactions transactions(Addresses const& _from, Addresses const& _to, std::vector<std::pair<u256, u256>> const& _stateAlterations, Addresses const& _altered, unsigned _ageFrom = 0, unsigned _ageTo, unsigned _max) const;
*/
// Misc stuff:
void setClientVersion(std::string const& _name) { m_clientVersion = _name; } void setClientVersion(std::string const& _name) { m_clientVersion = _name; }

39
libethereum/ExtVM.h

@ -29,56 +29,61 @@
namespace eth namespace eth
{ {
// TODO: Document /**
* @brief Externalality interface for the Virtual Machine providing access to world state.
*/
class ExtVM: public ExtVMFace class ExtVM: public ExtVMFace
{ {
public: public:
/// Full constructor.
ExtVM(State& _s, Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code): ExtVM(State& _s, Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code):
ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code, _s.m_previousBlock, _s.m_currentBlock), m_s(_s), m_origCache(_s.m_cache) ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code, _s.m_previousBlock, _s.m_currentBlock), m_s(_s), m_origCache(_s.m_cache)
{ {
m_s.ensureCached(_myAddress, true, true); m_s.ensureCached(_myAddress, true, true);
} }
u256 store(u256 _n) /// Read storage location.
{ u256 store(u256 _n) { return m_s.storage(myAddress, _n); }
return m_s.storage(myAddress, _n);
} /// Write a value in storage.
void setStore(u256 _n, u256 _v) void setStore(u256 _n, u256 _v) { m_s.setStorage(myAddress, _n, _v); }
{
m_s.setStorage(myAddress, _n, _v);
}
/// Create a new contract.
h160 create(u256 _endowment, u256* _gas, bytesConstRef _code) h160 create(u256 _endowment, u256* _gas, bytesConstRef _code)
{ {
// Increment associated nonce for sender. // Increment associated nonce for sender.
m_s.noteSending(myAddress); m_s.noteSending(myAddress);
return m_s.create(myAddress, _endowment, gasPrice, _gas, _code, origin); return m_s.create(myAddress, _endowment, gasPrice, _gas, _code, origin);
} }
/// Create a new message call.
bool call(Address _receiveAddress, u256 _txValue, bytesConstRef _txData, u256* _gas, bytesRef _out) bool call(Address _receiveAddress, u256 _txValue, bytesConstRef _txData, u256* _gas, bytesRef _out)
{ {
return m_s.call(_receiveAddress, myAddress, _txValue, gasPrice, _txData, _gas, _out, origin); return m_s.call(_receiveAddress, myAddress, _txValue, gasPrice, _txData, _gas, _out, origin);
} }
/// Read address's balance.
u256 balance(Address _a) { return m_s.balance(_a); } u256 balance(Address _a) { return m_s.balance(_a); }
/// Subtract amount from account's balance.
void subBalance(u256 _a) { m_s.subBalance(myAddress, _a); } void subBalance(u256 _a) { m_s.subBalance(myAddress, _a); }
/// Determine account's TX count.
u256 txCount(Address _a) { return m_s.transactionsFrom(_a); } u256 txCount(Address _a) { return m_s.transactionsFrom(_a); }
/// Suicide the associated contract to the given address.
void suicide(Address _a) void suicide(Address _a)
{ {
m_s.addBalance(_a, m_s.balance(myAddress)); m_s.addBalance(_a, m_s.balance(myAddress));
m_s.m_cache[myAddress].kill(); m_s.m_cache[myAddress].kill();
} }
void revert() /// Revert any changes made (by any of the other calls).
{ void revert() { m_s.m_cache = m_origCache; }
m_s.m_cache = m_origCache;
}
private: private:
State& m_s; State& m_s; ///< A reference to the base state.
std::map<Address, AddressState> m_origCache; std::map<Address, AddressState> m_origCache; ///< The cache of the address states (i.e. the externalities) as-was prior to the execution.
std::map<u256, u256>* m_store;
}; };
} }

10
libevm/ExtVMFace.h

@ -40,7 +40,6 @@ public:
/// Full constructor. /// Full constructor.
ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock); ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock);
/// Get the code at the given location in code ROM. /// Get the code at the given location in code ROM.
byte getCode(u256 _n) const { return _n < code.size() ? code[(unsigned)_n] : 0; } byte getCode(u256 _n) const { return _n < code.size() ? code[(unsigned)_n] : 0; }
@ -53,21 +52,24 @@ public:
/// Read address's balance. /// Read address's balance.
u256 balance(Address) { return 0; } u256 balance(Address) { return 0; }
/// Subtract amount from address's balance. /// Subtract amount from account's balance.
void subBalance(u256) {} void subBalance(u256) {}
/// Determine address's TX count. /// Determine account's TX count.
u256 txCount(Address) { return 0; } u256 txCount(Address) { return 0; }
/// Suicide the associated contract to the given address. /// Suicide the associated contract to the given address.
void suicide(Address) {} void suicide(Address) {}
/// Create a new contract. /// Create a new (contract) account.
h160 create(u256, u256*, bytesConstRef, bytesConstRef) { return h160(); } h160 create(u256, u256*, bytesConstRef, bytesConstRef) { return h160(); }
/// Make a new message call. /// Make a new message call.
bool call(Address, u256, bytesConstRef, u256*, bytesRef) { return false; } bool call(Address, u256, bytesConstRef, u256*, bytesRef) { return false; }
/// Revert any changes made (by any of the other calls).
void revert() {}
Address myAddress; ///< Address associated with executing code (a contract, or contract-to-be). Address myAddress; ///< Address associated with executing code (a contract, or contract-to-be).
Address caller; ///< Address which sent the message (either equal to origin or a contract). Address caller; ///< Address which sent the message (either equal to origin or a contract).
Address origin; ///< Original transactor. Address origin; ///< Original transactor.

7
liblll/All.h

@ -0,0 +1,7 @@
#pragma once
#include "Assembly.h"
#include "CodeFragment.h"
#include "Compiler.h"
#include "CompilerState.h"
#include "Parser.h"

9
libserpent/All.h

@ -0,0 +1,9 @@
#pragma once
#include "compiler.h"
#include "funcs.h"
#include "lllparser.h"
#include "parser.h"
#include "rewriter.h"
#include "tokenize.h"
#include "util.h"
Loading…
Cancel
Save