Browse Source

Bunch of repotting/curating.

[10:59:28] Vitalik Buterin: block.parent.gas_limit * 1023 / 1024 <=
block.gas_limit <= block.parent.gas_limit * 1025/1024
cl-refactor
Gav Wood 10 years ago
parent
commit
103b9ea0a7
  1. 2
      alethzero/Context.cpp
  2. 2
      alethzero/Context.h
  3. 2
      alethzero/Debugger.h
  4. 2
      alethzero/MainWin.h
  5. 2
      alethzero/Transact.h
  6. 12
      libdevcore/Base64.cpp
  7. 9
      libdevcore/Base64.h
  8. 6
      libdevcore/Common.h
  9. 1
      libdevcore/CommonIO.h
  10. 101
      libdevcore/CommonJS.cpp
  11. 116
      libdevcore/CommonJS.h
  12. 12
      libethcore/BlockInfo.cpp
  13. 2
      libethcore/BlockInfo.h
  14. 4
      libethcore/Common.cpp
  15. 2
      libethcore/Common.h
  16. 79
      libethcore/CommonJS.cpp
  17. 114
      libethcore/CommonJS.h
  18. 2
      libethcore/Exceptions.cpp
  19. 4
      libethcore/Exceptions.h
  20. 2
      libethcore/ProofOfWork.h
  21. 2
      libethereum/Account.cpp
  22. 2
      libethereum/AccountDiff.h
  23. 2
      libethereum/BlockChain.h
  24. 2
      libethereum/BlockQueue.h
  25. 2
      libethereum/CanonBlockChain.h
  26. 2
      libethereum/EthereumHost.h
  27. 2
      libethereum/EthereumPeer.h
  28. 2
      libethereum/Executive.h
  29. 2
      libethereum/ExtVM.h
  30. 2
      libethereum/LogFilter.h
  31. 2
      libethereum/Miner.h
  32. 2
      libethereum/Precompiled.cpp
  33. 2
      libethereum/Transaction.h
  34. 2
      libethereum/TransactionQueue.h
  35. 2
      libethereum/Utility.cpp
  36. 2
      libevm/ExtVMFace.h
  37. 2
      libevm/VM.h
  38. 2
      mix/QEther.h
  39. 94
      rlp/main.cpp
  40. 2
      test/MemTrie.cpp
  41. 2
      test/TrieHash.cpp
  42. 2
      test/commonjs.cpp
  43. 2
      third/MainWin.h

2
alethzero/Context.cpp

@ -21,7 +21,7 @@
#include "Context.h"
#include <QComboBox>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
using namespace std;
using namespace dev;
using namespace dev::eth;

2
alethzero/Context.h

@ -25,7 +25,7 @@
#include <vector>
#include <QString>
#include <QList>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
class QComboBox;

2
alethzero/Debugger.h

@ -22,7 +22,7 @@
#pragma once
#include <libdevcore/RLP.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethereum/State.h>
#include <libethereum/Executive.h>
#include <QDialog>

2
alethzero/MainWin.h

@ -32,7 +32,7 @@
#include <QtCore/QMutex>
#include <QtWidgets/QMainWindow>
#include <libdevcore/RLP.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethereum/State.h>
#include <libethereum/Executive.h>
#include <libwebthree/WebThree.h>

2
alethzero/Transact.h

@ -22,7 +22,7 @@
#pragma once
#include <libdevcore/RLP.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethereum/Transaction.h>
#include <QDialog>
#include <QMap>

12
rlp/base64.cpp → libdevcore/Base64.cpp

@ -23,13 +23,11 @@
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood.
#include "base64.h"
/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood.
#include "Base64.h"
#include <iostream>
using namespace std;
using namespace dev;
@ -42,7 +40,7 @@ static inline bool is_base64(byte c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
std::string dev::base64_encode(bytesConstRef _in) {
std::string dev::toBase64(bytesConstRef _in) {
std::string ret;
int i = 0;
int j = 0;
@ -86,7 +84,7 @@ std::string dev::base64_encode(bytesConstRef _in) {
return ret;
}
bytes dev::base64_decode(std::string const& encoded_string) {
bytes dev::fromBase64(std::string const& encoded_string) {
int in_len = encoded_string.size();
int i = 0;
int j = 0;

9
rlp/base64.h → libdevcore/Base64.h

@ -23,8 +23,9 @@
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood.
/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
/// Originally by René Nyffenegger.
/// DEVified by Gav Wood.
#pragma once
#include <vector>
@ -34,7 +35,7 @@
namespace dev
{
std::string base64_encode(bytesConstRef _in);
bytes base64_decode(std::string const& _in);
std::string toBase64(bytesConstRef _in);
bytes fromBase64(std::string const& _in);
}

6
libdevcore/Common.h

@ -119,6 +119,12 @@ inline unsigned int toLog2(u256 _x)
return ret;
}
template <class N>
inline N diff(N const& _a, N const& _b)
{
return std::max(_a, _b) - std::min(_a, _b);
}
/// RAII utility class whose destructor calls a given function.
class ScopeGuard {
public:

1
libdevcore/CommonIO.h

@ -36,6 +36,7 @@
#include <string>
#include <iostream>
#include "Common.h"
#include "Base64.h"
namespace dev
{

101
libdevcore/CommonJS.cpp

@ -0,0 +1,101 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CommonJS.cpp
* @authors:
* Gav Wood <i@gavwood.com>
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
#include "CommonJS.h"
namespace dev
{
bytes jsToBytes(std::string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return fromHex(_s.substr(2));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return toCompactBigEndian(bigint(_s));
else
return bytes();
}
bytes padded(bytes _b, unsigned _l)
{
while (_b.size() < _l)
_b.insert(_b.begin(), 0);
return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l)));
}
bytes paddedRight(bytes _b, unsigned _l)
{
_b.resize(_l);
return _b;
}
bytes unpadded(bytes _b)
{
auto p = asString(_b).find_last_not_of((char)0);
_b.resize(p == std::string::npos ? 0 : (p + 1));
return _b;
}
bytes unpadLeft(bytes _b)
{
unsigned int i = 0;
if (_b.size() == 0)
return _b;
while (i < _b.size() && _b[i] == byte(0))
i++;
if (i != 0)
_b.erase(_b.begin(), _b.begin() + i);
return _b;
}
std::string fromRaw(h256 _n, unsigned* _inc)
{
if (_n)
{
std::string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return "";
if (l != std::string::npos)
{
auto p = s.find_first_not_of('\0', l);
if (!(p == std::string::npos || (_inc && p == 31)))
return "";
if (_inc)
*_inc = (byte)s[31];
s.resize(l);
}
for (auto i: s)
if (i < 32)
return "";
return s;
}
return "";
}
}

116
libdevcore/CommonJS.h

@ -0,0 +1,116 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CommonJS.h
* @authors:
* Gav Wood <i@gavwood.com>
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
#pragma once
#include <string>
#include "FixedHash.h"
#include "CommonData.h"
#include "CommonIO.h"
namespace dev
{
template <unsigned S> std::string toJS(FixedHash<S> const& _h)
{
return "0x" + toHex(_h.ref());
}
template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n)
{
return "0x" + toHex(toCompactBigEndian(_n));
}
inline std::string toJS(dev::bytes const& _n)
{
return "0x" + dev::toHex(_n);
}
/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex.
bytes jsToBytes(std::string const& _s);
/// Add '0' on the head of @a _b until @a _l.
bytes padded(bytes _b, unsigned _l);
/// Add '0' on the queue of @a _b until @a _l.
bytes paddedRight(bytes _b, unsigned _l);
/// Removing all trailing '0'. Returns empty array if input contains only '0' char.
bytes unpadded(bytes _s);
/// Remove all 0 byte on the head of @a _s.
bytes unpadLeft(bytes _s);
/// Convert h256 into user-readable string (by directly using std::string constructor).
std::string fromRaw(h256 _n, unsigned* _inc = nullptr);
template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return FixedHash<N>(_s.substr(2 + std::max<unsigned>(N * 2, _s.size() - 2) - N * 2));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return (typename FixedHash<N>::Arith)(_s);
else
// Binary
return FixedHash<N>(); // FAIL
}
inline std::string jsToFixed(double _s)
{
return toJS(dev::u256(_s * (double)(dev::u256(1) << 128)));
}
template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> jsToInt(std::string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(fromHex(_s.substr(2)));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>(_s);
else
// Binary
return 0; // FAIL
}
inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
inline std::string jsToDecimal(std::string const& _s)
{
return dev::toString(jsToU256(_s));
}
inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32)
{
_s.resize(std::max<unsigned>(_s.size(), _padding));
return "0x" + dev::toHex(_s);
}
inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32)
{
return jsFromBinary(asBytes(_s), _padding);
}
inline double jsFromFixed(std::string const& _s)
{
return (double)jsToU256(_s) / (double)(dev::u256(1) << 128);
}
}

12
libethcore/BlockInfo.cpp

@ -22,7 +22,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/TrieDB.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include "ProofOfWork.h"
#include "Exceptions.h"
#include "Params.h"
@ -203,15 +203,15 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const
return max<u256>(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor)));
}
template <class N> inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); }
void BlockInfo::verifyParent(BlockInfo const& _parent) const
{ // Check difficulty is correct given the two timestamps.
{
// Check difficulty is correct given the two timestamps.
if (difficulty != calculateDifficulty(_parent))
BOOST_THROW_EXCEPTION(InvalidDifficulty());
if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor)
BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor));
if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor ||
gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)
BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor));
if (seedHash != calculateSeedHash(_parent))
BOOST_THROW_EXCEPTION(InvalidSeedHash());

2
libethcore/BlockInfo.h

@ -23,7 +23,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include "CommonEth.h"
#include "Common.h"
namespace dev
{

4
libethcore/CommonEth.cpp → libethcore/Common.cpp

@ -14,12 +14,12 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CommonEth.cpp
/** @file Common.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "CommonEth.h"
#include "Common.h"
#include <random>
#include <libdevcrypto/SHA3.h>
#include "Exceptions.h"

2
libethcore/CommonEth.h → libethcore/Common.h

@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CommonEth.h
/** @file Common.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*

79
libethcore/CommonJS.cpp

@ -26,75 +26,12 @@
namespace dev
{
bytes jsToBytes(std::string const& _s)
Address toAddress(std::string const& _sn)
{
if (_s.substr(0, 2) == "0x")
// Hex
return fromHex(_s.substr(2));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return toCompactBigEndian(bigint(_s));
if (_sn.size() == 40)
return Address(fromHex(_sn));
else
return bytes();
}
bytes padded(bytes _b, unsigned _l)
{
while (_b.size() < _l)
_b.insert(_b.begin(), 0);
return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l)));
}
bytes paddedRight(bytes _b, unsigned _l)
{
_b.resize(_l);
return _b;
}
bytes unpadded(bytes _b)
{
auto p = asString(_b).find_last_not_of((char)0);
_b.resize(p == std::string::npos ? 0 : (p + 1));
return _b;
}
bytes unpadLeft(bytes _b)
{
unsigned int i = 0;
if (_b.size() == 0)
return _b;
while (i < _b.size() && _b[i] == byte(0))
i++;
if (i != 0)
_b.erase(_b.begin(), _b.begin() + i);
return _b;
}
std::string fromRaw(h256 _n, unsigned* _inc)
{
if (_n)
{
std::string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return "";
if (l != std::string::npos)
{
auto p = s.find_first_not_of('\0', l);
if (!(p == std::string::npos || (_inc && p == 31)))
return "";
if (_inc)
*_inc = (byte)s[31];
s.resize(l);
}
for (auto i: s)
if (i < 32)
return "";
return s;
}
return "";
return Address();
}
std::string prettyU256(u256 _n, bool _abridged)
@ -128,13 +65,5 @@ std::string prettyU256(u256 _n, bool _abridged)
return s.str();
}
Address fromString(std::string const& _sn)
{
if (_sn.size() == 40)
return Address(fromHex(_sn));
else
return Address();
}
}

114
libethcore/CommonJS.h

@ -24,124 +24,38 @@
#pragma once
#include <string>
#include <libdevcore/Common.h>
#include <libdevcore/FixedHash.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/CommonIO.h>
#include "CommonEth.h"
#include <libdevcore/CommonJS.h>
#include <libdevcrypto/Common.h>
#include "Common.h"
// devcrypto
namespace dev
{
template <unsigned S> std::string toJS(FixedHash<S> const& _h)
{
return "0x" + toHex(_h.ref());
}
/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40).
Address toAddress(std::string const& _a);
template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n)
{
return "0x" + toHex(toCompactBigEndian(_n));
}
/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length.
inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
inline std::string toJS(dev::bytes const& _n)
{
return "0x" + dev::toHex(_n);
}
/// Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length.
inline Secret jsToSecret(std::string const& _s) { return jsToFixed<sizeof(dev::Secret)>(_s); }
/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length.
inline Address jsToAddress(std::string const& _s) { return jsToFixed<sizeof(dev::Address)>(_s); }
/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex.
bytes jsToBytes(std::string const& _s);
/// Add '0' on the head of @a _b until @a _l.
bytes padded(bytes _b, unsigned _l);
/// Add '0' on the queue of @a _b until @a _l.
bytes paddedRight(bytes _b, unsigned _l);
/// Removing all trailing '0'. Returns empty array if input contains only '0' char.
bytes unpadded(bytes _s);
/// Remove all 0 byte on the head of @a _s.
bytes unpadLeft(bytes _s);
/// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256.
std::string prettyU256(u256 _n, bool _abridged = true);
/// Convert h256 into user-readable string (by directly using std::string constructor).
std::string fromRaw(h256 _n, unsigned* _inc = nullptr);
/// Convert string to Address (h160), returns empty address if (_a.size != 40).
Address fromString(std::string const& _a);
template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return FixedHash<N>(_s.substr(2 + std::max<unsigned>(N * 2, _s.size() - 2) - N * 2));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return (typename FixedHash<N>::Arith)(_s);
else
// Binary
return FixedHash<N>(); // FAIL
}
inline std::string jsToFixed(double _s)
{
return toJS(dev::u256(_s * (double)(dev::u256(1) << 128)));
}
template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> jsToInt(std::string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(fromHex(_s.substr(2)));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal
return boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>(_s);
else
// Binary
return 0; // FAIL
}
inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
inline std::string jsToDecimal(std::string const& _s)
{
return dev::toString(jsToU256(_s));
}
inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32)
{
_s.resize(std::max<unsigned>(_s.size(), _padding));
return "0x" + dev::toHex(_s);
}
inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32)
{
return jsFromBinary(asBytes(_s), _padding);
}
inline double jsFromFixed(std::string const& _s)
{
return (double)jsToU256(_s) / (double)(dev::u256(1) << 128);
}
}
// devcrypto
#include <libdevcrypto/Common.h>
namespace dev
{
inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
inline Secret jsToSecret(std::string const& _s) { return jsToFixed<sizeof(dev::Secret)>(_s); }
}
// ethcore
namespace dev
{
namespace eth
{
inline Address jsToAddress(std::string const& _s) { return jsToFixed<sizeof(dev::Address)>(_s); }
struct TransactionSkeleton
{
bool creation = false;

2
libethcore/Exceptions.cpp

@ -39,7 +39,7 @@ static boost::thread_specific_ptr<string> g_exceptionMessage;
const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); }
const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); }
const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); }
const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); }
const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); }
const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); }
const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); }
const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); }

4
libethcore/Exceptions.h

@ -22,7 +22,7 @@
#pragma once
#include <libdevcore/Exceptions.h>
#include "CommonEth.h"
#include "Common.h"
namespace dev
{
@ -58,7 +58,7 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr
struct InvalidTransaction: virtual dev::Exception {};
struct InvalidDifficulty: virtual dev::Exception {};
struct InvalidSeedHash: virtual dev::Exception {};
class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; };
class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; };
class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; };
struct InvalidTransactionGasUsed: virtual dev::Exception {};
struct InvalidTransactionsStateRoot: virtual dev::Exception {};

2
libethcore/ProofOfWork.h

@ -27,7 +27,7 @@
#include <thread>
#include <cstdint>
#include <libdevcrypto/SHA3.h>
#include "CommonEth.h"
#include "Common.h"
#include "BlockInfo.h"
#define FAKE_DAGGER 1

2
libethereum/Account.cpp

@ -20,7 +20,7 @@
*/
#include "Account.h"
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
using namespace std;
using namespace dev;
using namespace dev::eth;

2
libethereum/AccountDiff.h

@ -23,7 +23,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/Diff.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
namespace dev
{

2
libethereum/BlockChain.h

@ -29,7 +29,7 @@
#include <mutex>
#include <libdevcore/Log.h>
#include <libdevcore/Exceptions.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethcore/BlockInfo.h>
#include <libdevcore/Guards.h>
#include "BlockDetails.h"

2
libethereum/BlockQueue.h

@ -24,7 +24,7 @@
#include <boost/thread.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/Log.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libdevcore/Guards.h>
namespace dev

2
libethereum/CanonBlockChain.h

@ -29,7 +29,7 @@
#include <mutex>
#include <libdevcore/Log.h>
#include <libdevcore/Exceptions.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethcore/BlockInfo.h>
#include <libdevcore/Guards.h>
#include "BlockDetails.h"

2
libethereum/EthereumHost.h

@ -32,7 +32,7 @@
#include <libdevcore/Guards.h>
#include <libdevcore/Worker.h>
#include <libdevcore/RangeMask.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libp2p/Common.h>
#include "CommonNet.h"
#include "EthereumPeer.h"

2
libethereum/EthereumPeer.h

@ -33,7 +33,7 @@
#include <libdevcore/RLP.h>
#include <libdevcore/Guards.h>
#include <libdevcore/RangeMask.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libp2p/Capability.h>
#include "CommonNet.h"
#include "DownloadMan.h"

2
libethereum/Executive.h

@ -21,7 +21,7 @@
#include <functional>
#include <libdevcore/Log.h>
#include <libevmcore/Instruction.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libevm/VMFace.h>
#include "Transaction.h"

2
libethereum/ExtVM.h

@ -23,7 +23,7 @@
#include <map>
#include <functional>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libevm/ExtVMFace.h>
#include "State.h"

2
libethereum/LogFilter.h

@ -23,7 +23,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include "TransactionReceipt.h"
namespace dev

2
libethereum/Miner.h

@ -27,7 +27,7 @@
#include <atomic>
#include <libdevcore/Common.h>
#include <libdevcore/Worker.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include "State.h"
namespace dev

2
libethereum/Precompiled.cpp

@ -23,7 +23,7 @@
#include <libdevcrypto/SHA3.h>
#include <libdevcrypto/Common.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethcore/Params.h>
using namespace std;
using namespace dev;

2
libethereum/Transaction.h

@ -23,7 +23,7 @@
#include <libdevcore/RLP.h>
#include <libdevcrypto/SHA3.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
namespace dev
{

2
libethereum/TransactionQueue.h

@ -23,7 +23,7 @@
#include <boost/thread.hpp>
#include <libdevcore/Common.h>
#include "libethcore/CommonEth.h"
#include "libethcore/Common.h"
#include <libdevcore/Guards.h>
namespace dev

2
libethereum/Utility.cpp

@ -22,7 +22,7 @@
#include "Utility.h"
#include <boost/regex.hpp>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libdevcrypto/SHA3.h>
using namespace std;
using namespace dev;

2
libevm/ExtVMFace.h

@ -28,7 +28,7 @@
#include <libdevcore/RLP.h>
#include <libdevcrypto/SHA3.h>
#include <libevmcore/Instruction.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethcore/BlockInfo.h>
namespace dev

2
libevm/VM.h

@ -23,7 +23,7 @@
#include <unordered_map>
#include <libdevcore/Exceptions.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libevmcore/Instruction.h>
#include <libdevcrypto/SHA3.h>
#include <libethcore/BlockInfo.h>

2
mix/QEther.h

@ -23,7 +23,7 @@
#pragma once
#include <QObject>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include "QBigInt.h"
namespace dev

94
rlp/main.cpp

@ -22,11 +22,9 @@
#include <fstream>
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/SHA3.h>
#include "base64.h"
using namespace std;
using namespace dev;
@ -218,7 +216,7 @@ int main(int argc, char** argv)
boost::algorithm::replace_all(s, " ", "");
boost::algorithm::replace_all(s, "\n", "");
boost::algorithm::replace_all(s, "\t", "");
b = base64_decode(s);
b = fromBase64(s);
break;
}
default:
@ -228,60 +226,60 @@ int main(int argc, char** argv)
try
{
RLP rlp(b);
switch (mode)
{
case Mode::ListArchive:
{
if (!rlp.isList())
RLP rlp(b);
switch (mode)
{
cout << "Error: Invalid format; RLP data is not a list." << endl;
exit(1);
}
cout << rlp.itemCount() << " items:" << endl;
for (auto i: rlp)
case Mode::ListArchive:
{
if (!i.isData())
if (!rlp.isList())
{
cout << "Error: Invalid format; RLP list item is not data." << endl;
if (!lenience)
exit(1);
cout << "Error: Invalid format; RLP data is not a list." << endl;
exit(1);
}
cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl;
}
break;
}
case Mode::ExtractArchive:
{
if (!rlp.isList())
{
cout << "Error: Invalid format; RLP data is not a list." << endl;
exit(1);
cout << rlp.itemCount() << " items:" << endl;
for (auto i: rlp)
{
if (!i.isData())
{
cout << "Error: Invalid format; RLP list item is not data." << endl;
if (!lenience)
exit(1);
}
cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl;
}
break;
}
cout << rlp.itemCount() << " items:" << endl;
for (auto i: rlp)
case Mode::ExtractArchive:
{
if (!i.isData())
if (!rlp.isList())
{
cout << "Error: Invalid format; RLP list item is not data." << endl;
if (!lenience)
exit(1);
cout << "Error: Invalid format; RLP data is not a list." << endl;
exit(1);
}
ofstream fout;
fout.open(toString(sha3(i.data())));
fout.write(reinterpret_cast<char const*>(i.data().data()), i.data().size());
cout << rlp.itemCount() << " items:" << endl;
for (auto i: rlp)
{
if (!i.isData())
{
cout << "Error: Invalid format; RLP list item is not data." << endl;
if (!lenience)
exit(1);
}
ofstream fout;
fout.open(toString(sha3(i.data())));
fout.write(reinterpret_cast<char const*>(i.data().data()), i.data().size());
}
break;
}
case Mode::Render:
{
RLPStreamer s(cout, prefs);
s.output(rlp);
cout << endl;
break;
}
default:;
}
break;
}
case Mode::Render:
{
RLPStreamer s(cout, prefs);
s.output(rlp);
cout << endl;
break;
}
default:;
}
}
catch (...)
{

2
test/MemTrie.cpp

@ -23,7 +23,7 @@
#include <libdevcrypto/TrieCommon.h>
#include <libdevcrypto/SHA3.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
using namespace std;
using namespace dev;
using namespace dev::eth;

2
test/TrieHash.cpp

@ -23,7 +23,7 @@
#include <libdevcrypto/TrieCommon.h>
#include <libdevcrypto/SHA3.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
using namespace std;
using namespace dev;
using namespace dev::eth;

2
test/commonjs.cpp

@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress)
cnote << "Testing jsToPublic...";
KeyPair kp = KeyPair::create();
string string = toJS(kp.address());
Address address = dev::eth::jsToAddress(string);
Address address = dev::jsToAddress(string);
BOOST_CHECK_EQUAL(kp.address(), address);
}

2
third/MainWin.h

@ -28,7 +28,7 @@
#include <QtCore/QMutex>
#include <QtWidgets/QMainWindow>
#include <libdevcore/RLP.h>
#include <libethcore/CommonEth.h>
#include <libethcore/Common.h>
#include <libethereum/State.h>
namespace Ui {

Loading…
Cancel
Save