Browse Source

Remove unnecessary code

cl-refactor
Paweł Bylica 8 years ago
parent
commit
1b081b5a37
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 27
      libethcore/BlockInfo.cpp
  2. 7
      libethcore/CMakeLists.txt
  3. 31
      libethcore/Common.h
  4. 75
      libethcore/Params.cpp
  5. 43
      libethcore/Params.h

27
libethcore/BlockInfo.cpp

@ -23,7 +23,6 @@
#include <libdevcore/Log.h>
#include <libdevcore/RLP.h>
#include <libethcore/Common.h>
#include <libethcore/Params.h>
#include "EthashAux.h"
#include "Exceptions.h"
#include "BlockInfo.h"
@ -140,29 +139,3 @@ void BlockInfo::populateFromHeader(RLP const& _header, Strictness _s)
if (_s != CheckNothing && m_gasUsed > m_gasLimit)
BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(m_gasLimit), bigint(m_gasUsed)));
}
struct BlockInfoDiagnosticsChannel: public LogChannel { static const char* name() { return EthBlue "" EthWhite ""; } static const int verbosity = 9; };
u256 BlockInfo::childGasLimit(u256 const& _gasFloorTarget) const
{
u256 gasFloorTarget =
_gasFloorTarget == UndefinedU256 ? c_gasFloorTarget : _gasFloorTarget;
if (m_gasLimit < gasFloorTarget)
return min<u256>(gasFloorTarget, m_gasLimit + m_gasLimit / c_gasLimitBoundDivisor - 1);
else
return max<u256>(gasFloorTarget, m_gasLimit - m_gasLimit / c_gasLimitBoundDivisor + 1 + (m_gasUsed * 6 / 5) / c_gasLimitBoundDivisor);
}
u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const
{
const unsigned c_expDiffPeriod = 100000;
if (!m_number)
throw GenesisBlockCannotBeCalculated();
u256 o = max<u256>(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor)));
unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod;
if (periodCount > 1)
o = max<u256>(c_minimumDifficulty, o + (u256(1) << (periodCount - 2))); // latter will eventually become huge, so ensure it's a bigint.
return o;
}

7
libethcore/CMakeLists.txt

@ -1,6 +1,7 @@
cmake_policy(SET CMP0015 NEW)
file(GLOB SRC_LIST "*.cpp")
file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")
include_directories(BEFORE ..)
include_directories(${Boost_INCLUDE_DIRS})
@ -9,9 +10,7 @@ if (ETHASHCUDA)
include_directories(${CUDA_INCLUDE_DIRS})
endif ()
file(GLOB HEADERS "*.h")
add_library(ethcore ${SRC_LIST} ${HEADERS})
add_library(ethcore ${SOURCES} ${HEADERS})
target_link_libraries(ethcore ethash pthread)
if (ETHASHCL)

31
libethcore/Common.h

@ -34,49 +34,18 @@ namespace dev
namespace eth
{
/// The network id.
enum class Network
{
Olympic = 0,
Frontier = 1,
Turbo = 2
};
extern Network c_network;
Network resetNetwork(Network _n);
/// An Ethereum address: 20 bytes.
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
using Address = h160;
DEV_SIMPLE_EXCEPTION(InvalidAddress);
/// Get information concerning the currency denominations.
std::vector<std::pair<u256, std::string>> const& units();
/// The log bloom's size (2048-bit).
using LogBloom = h2048;
/// Many log blooms.
using LogBlooms = std::vector<LogBloom>;
template <size_t n> inline u256 exp10()
{
return exp10<n - 1>() * u256(10);
}
template <> inline u256 exp10<0>()
{
return u256(1);
}
// The various denominations; here for ease of use where needed within code.
static const u256 ether = exp10<18>();
static const u256 finney = exp10<15>();
static const u256 szabo = exp10<12>();
static const u256 shannon = exp10<9>();
static const u256 wei = exp10<0>();
using Nonce = h64;
using BlockNumber = unsigned;

75
libethcore/Params.cpp

@ -1,75 +0,0 @@
/*
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 Params.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "Params.h"
#include "Common.h"
using namespace std;
namespace dev
{
namespace eth
{
//--- BEGIN: AUTOGENERATED FROM github.com/ethereum/common/params.json
u256 c_maximumExtraDataSize;
u256 c_minGasLimit;
u256 c_gasLimitBoundDivisor;
u256 c_minimumDifficulty;
u256 c_difficultyBoundDivisor;
u256 c_durationLimit;
u256 c_blockReward;
u256 c_gasFloorTarget;
//--- END: AUTOGENERATED FROM /feeStructure.json
#if ETH_FRONTIER
Network c_network = resetNetwork(Network::Frontier);
#else
Network c_network = resetNetwork(Network::Olympic);
#endif
Network resetNetwork(Network _n)
{
c_network = _n;
c_maximumExtraDataSize = c_network == Network::Olympic ? 1024 : 32;
switch(_n)
{
case Network::Turbo:
c_minGasLimit = 100000000;
break;
case Network::Olympic:
c_minGasLimit = 125000;
break;
case Network::Frontier:
c_minGasLimit = 5000;
break;
}
c_gasFloorTarget = 3141592;
c_gasLimitBoundDivisor = 1024;
c_minimumDifficulty = 131072;
c_difficultyBoundDivisor = 2048;
c_durationLimit = c_network == Network::Turbo ? 2 : c_network == Network::Olympic ? 8 : 13;
c_blockReward = c_network == Network::Olympic ? (1500 * finney) : (5 * ether);
return _n;
}
}
}

43
libethcore/Params.h

@ -1,43 +0,0 @@
/*
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 Params.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#pragma once
#include <libdevcore/Common.h>
namespace dev
{
namespace eth
{
//--- BEGIN: AUTOGENERATED FROM /feeStructure.json
extern u256 c_minGasLimit;
extern u256 c_gasLimitBoundDivisor;
extern u256 c_minimumDifficulty;
extern u256 c_difficultyBoundDivisor;
extern u256 c_durationLimit;
extern u256 c_maximumExtraDataSize;
extern u256 c_blockReward;
extern u256 c_gasFloorTarget;
//--- END: AUTOGENERATED FROM /feeStructure.json
}
}
Loading…
Cancel
Save