Browse Source

Frontier parameters in.

cl-refactor
Gav Wood 10 years ago
parent
commit
c7c1d79176
  1. 6
      libethcore/Common.cpp
  2. 8
      libethcore/Common.h
  3. 3
      libethcore/Params.cpp
  4. 2
      libethereum/BlockQueue.cpp
  5. 2
      libethereum/Client.cpp
  6. 2
      libethereum/State.cpp
  7. 15
      libp2p/RLPxHandshake.cpp

6
libethcore/Common.cpp

@ -46,6 +46,12 @@ const unsigned c_databaseBaseVersion = 9;
const unsigned c_databaseVersionModifier = 0;
#endif
#if ETH_FRONTIER
Network const c_network = Network::Frontier;
#else
Network const c_network = Network::Olympic;
#endif
const unsigned c_databaseVersion = c_databaseBaseVersion + (c_databaseVersionModifier << 8) + (ProofOfWork::revision() << 9);
vector<pair<u256, string>> const& units()

8
libethcore/Common.h

@ -43,6 +43,14 @@ extern const unsigned c_minorProtocolVersion;
/// Current database version.
extern const unsigned c_databaseVersion;
/// The network id.
enum class Network
{
Olympic = 0,
Frontier = 1
};
extern const Network c_network;
/// User-friendly string representation of the amount _b in wei.
std::string formatBalance(bigint const& _b);

3
libethcore/Params.cpp

@ -20,6 +20,7 @@
*/
#include "Params.h"
#include "Common.h"
using namespace std;
namespace dev
@ -35,7 +36,7 @@ u256 const c_minGasLimit = 125000;
u256 const c_gasLimitBoundDivisor = 1024;
u256 const c_minimumDifficulty = 131072;
u256 const c_difficultyBoundDivisor = 2048;
u256 const c_durationLimit = 8;
u256 const c_durationLimit = c_network == Network::Olympic ? 8 : 12;
//--- END: AUTOGENERATED FROM /feeStructure.json
}

2
libethereum/BlockQueue.cpp

@ -81,7 +81,7 @@ void BlockQueue::verifierBody()
res.first.populate(res.second, CheckEverything, work.first);
res.first.verifyInternals(&res.second);
}
catch (InvalidNonce&)
catch (InvalidBlockNonce&)
{
badBlock(res.second, "Invalid block nonce");
cwarn << " Nonce:" << res.first.nonce.hex();

2
libethereum/Client.cpp

@ -665,7 +665,7 @@ void Client::doWork()
syncBlockQueue();
t = true;
if (m_syncTransactionQueue.compare_exchange_strong(t, false) && !m_remoteWorking)
if (m_syncTransactionQueue.compare_exchange_strong(t, false) && !m_remoteWorking && !isSyncing())
syncTransactionQueue();
tick();

2
libethereum/State.cpp

@ -46,7 +46,7 @@ using namespace dev::eth;
#define ctrace clog(StateTrace)
#define ETH_TIMED_ENACTMENTS 0
static const u256 c_blockReward = 1500 * finney;
static const u256 c_blockReward = c_network == Network::Olympic ? (1500 * finney) : (5 * ether);
const char* StateSafeExceptions::name() { return EthViolet "" EthBlue ""; }
const char* StateDetail::name() { return EthViolet "" EthWhite ""; }

15
libp2p/RLPxHandshake.cpp

@ -184,7 +184,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
// old packet format
// 5 arguments, HelloPacket
RLPStream s;
s.append((unsigned)0).appendList(5)
s.append((unsigned)HelloPacket).appendList(5)
<< dev::p2p::c_protocolVersion
<< m_host->m_clientVersion
<< m_host->caps()
@ -205,15 +205,16 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
m_nextState = StartSession;
// read frame header
m_handshakeInBuffer.resize(h256::size);
ba::async_read(m_socket->ref(), boost::asio::buffer(m_handshakeInBuffer, h256::size), [this, self](boost::system::error_code ec, std::size_t)
unsigned const handshakeSize = 32;
m_handshakeInBuffer.resize(handshakeSize);
ba::async_read(m_socket->ref(), boost::asio::buffer(m_handshakeInBuffer, handshakeSize), [this, self](boost::system::error_code ec, std::size_t)
{
if (ec)
transition(ec);
else
{
/// authenticate and decrypt header
if (!m_io->authAndDecryptHeader(bytesRef(m_handshakeInBuffer.data(), h256::size)))
if (!m_io->authAndDecryptHeader(bytesRef(m_handshakeInBuffer.data(), handshakeSize)))
{
m_nextState = Error;
transition();
@ -235,7 +236,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
}
/// rlp of header has protocol-type, sequence-id[, total-packet-size]
bytes headerRLP(header.size() - 3 - h128::size);
bytes headerRLP(header.size() - 3 - h128::size); // this is always 32 - 3 - 16 = 13. wtf?
bytesConstRef(&header).cropped(3).copyTo(&headerRLP);
/// read padded frame and mac
@ -255,8 +256,8 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
return;
}
PacketType packetType = (PacketType)(frame[0] == 0x80 ? 0x0 : frame[0]);
if (packetType != 0)
PacketType packetType = frame[0] == 0x80 ? HelloPacket : (PacketType)frame[0];
if (packetType != HelloPacket)
{
clog(NetTriviaSummary) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame: invalid packet type";
m_nextState = Error;

Loading…
Cancel
Save