Browse Source

Merge branch 'poc-6'

cl-refactor
Tim Hughes 11 years ago
parent
commit
a28e910fc2
  1. 3
      alethzero/MainWin.h
  2. 8
      eth/main.cpp
  3. 2
      libdevcore/_libdevcore.cpp
  4. 2
      libethcore/Exceptions.h
  5. 11
      libethereum/DownloadMan.h
  6. 2
      libethereum/EthereumHost.cpp
  7. 1
      libethereum/EthereumPeer.cpp
  8. 7
      libethereum/State.cpp
  9. 2
      libwebthree/WebThree.h
  10. 1
      windows/Alethzero.vcxproj
  11. 2
      windows/Alethzero.vcxproj.filters
  12. 28
      windows/LibEthereum.vcxproj
  13. 27
      windows/LibEthereum.vcxproj.filters

3
alethzero/MainWin.h

@ -21,6 +21,9 @@
#pragma once
#ifdef Q_MOC_RUN
#define BOOST_MPL_IF_HPP_INCLUDED
#endif
#include <map>
#include <QtNetwork/QNetworkAccessManager>

8
eth/main.cpp

@ -300,7 +300,13 @@ int main(int argc, char** argv)
cout << credits();
NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
dev::WebThreeDirect web3("Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), dbPath, false, mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>{}, netPrefs);
dev::WebThreeDirect web3(
"Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM),
dbPath,
false,
mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(),
netPrefs
);
web3.setIdealPeerCount(peers);
eth::Client* c = mode == NodeMode::Full ? web3.ethereum() : nullptr;

2
libdevcore/_libdevcore.cpp

@ -6,5 +6,7 @@
#include "FixedHash.cpp"
#include "Guards.cpp"
#include "Log.cpp"
#include "RangeMask.cpp"
#include "RLP.cpp"
#include "Worker.cpp"
#endif

2
libethcore/Exceptions.h

@ -25,7 +25,7 @@ class InvalidBlockHeaderFormat: public dev::Exception { public: InvalidBlockHead
class InvalidUnclesHash: public dev::Exception {};
class InvalidUncle: public dev::Exception {};
class UncleTooOld: public dev::Exception {};
class UncleInChain: public dev::Exception {};
class UncleInChain: public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual std::string description() const { return "Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"; } };
class DuplicateUncleNonce: public dev::Exception {};
class InvalidStateRoot: public dev::Exception {};
class InvalidTransactionsHash: public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual std::string description() const { return "Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref()); } };

11
libethereum/DownloadMan.h

@ -101,6 +101,17 @@ public:
m_blocksGot = RangeMask<unsigned>(0, m_chain.size());
}
void reset()
{
{
ReadGuard l(x_subs);
for (auto i: m_subs)
i->resetFetch();
}
m_chain.clear();
m_blocksGot.clear();
}
RangeMask<unsigned> taken(bool _desperate = false) const
{
auto ret = m_blocksGot;

2
libethereum/EthereumHost.cpp

@ -149,6 +149,7 @@ void EthereumHost::noteDoneBlocks(EthereumPeer* _who)
// Done our chain-get.
clog(NetNote) << "Chain download complete.";
updateGrabbing(Grabbing::Nothing);
m_man.reset();
}
if (_who->m_grabbing == Grabbing::Chain)
{
@ -156,6 +157,7 @@ void EthereumHost::noteDoneBlocks(EthereumPeer* _who)
clog(NetNote) << "Chain download failed. Peer with blocks didn't have them all. This peer is bad and should be punished.";
// TODO: note that peer is BADBADBAD!
updateGrabbing(Grabbing::Nothing);
m_man.reset();
}
}

1
libethereum/EthereumPeer.cpp

@ -246,6 +246,7 @@ bool EthereumPeer::interpret(RLP const& _r)
// Couldn't get any from last batch - probably got to this peer's latest block - just give up.
m_sub.doneFetch();
giveUpOnFetch();
break;
}
unsigned used = 0;

7
libethereum/State.cpp

@ -577,6 +577,9 @@ u256 State::enact(bytesConstRef _block, BlockChain const* _bc, bool _checkNonce)
set<h256> knownUncles = _bc ? _bc->allUnclesFrom(m_currentBlock.parentHash) : set<h256>();
for (auto const& i: RLP(_block)[2])
{
if (knownUncles.count(sha3(i.data())))
throw UncleInChain(knownUncles, sha3(i.data()));
BlockInfo uncle = BlockInfo::fromHeader(i.data());
if (nonces.count(uncle.nonce))
throw DuplicateUncleNonce();
@ -585,8 +588,6 @@ u256 State::enact(bytesConstRef _block, BlockChain const* _bc, bool _checkNonce)
BlockInfo uncleParent(_bc->block(uncle.parentHash));
if ((bigint)uncleParent.number < (bigint)m_currentBlock.number - 6)
throw UncleTooOld();
if (knownUncles.count(sha3(i.data())))
throw UncleInChain();
uncle.verifyParent(uncleParent);
}
@ -725,7 +726,7 @@ void State::commitToMine(BlockChain const& _bc)
auto us = _bc.details(p).children;
assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent!
for (auto const& u: us)
if (!knownUncles.count(BlockInfo::headerHash(_bc.block(u)))) // ignore any uncles/mainline blocks that we know about. We use header-hash for this.
if (!knownUncles.count(u)) // ignore any uncles/mainline blocks that we know about.
{
BlockInfo ubi(_bc.block(u));
ubi.fillStream(unclesData, true);

2
libwebthree/WebThree.h

@ -93,7 +93,7 @@ public:
void connect(std::string const& _seedHost, unsigned short _port = 30303);
/// Is the network subsystem up?
bool haveNetwork() { return peerCount(); }
bool haveNetwork() { return peerCount() != 0; }
/// Save peers
dev::bytes savePeers();

1
windows/Alethzero.vcxproj

@ -176,6 +176,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\alethzero\DownloadView.cpp" />
<ClCompile Include="..\alethzero\Grapher.cpp" />
<ClCompile Include="..\alethzero\main.cpp" />
<ClCompile Include="..\alethzero\MainWin.cpp" />

2
windows/Alethzero.vcxproj.filters

@ -11,6 +11,7 @@
</ClCompile>
<ClCompile Include="..\alethzero\Grapher.cpp" />
<ClCompile Include="..\alethzero\MiningView.cpp" />
<ClCompile Include="..\alethzero\DownloadView.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -31,5 +32,6 @@
<Filter>Windows</Filter>
</CustomBuild>
<CustomBuild Include="..\alethzero\MiningView.h" />
<CustomBuild Include="..\alethzero\DownloadView.h" />
</ItemGroup>
</Project>

28
windows/LibEthereum.vcxproj

@ -49,12 +49,24 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libdevcore\RangeMask.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libdevcore\RLP.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libdevcore\Worker.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libdevcore\_libdevcore.cpp" />
<ClCompile Include="..\libdevcrypto\Common.cpp" />
<ClCompile Include="..\libdevcrypto\FileSystem.cpp" />
@ -90,6 +102,7 @@
<ClCompile Include="..\libethereum\Client.cpp" />
<ClCompile Include="..\libethereum\CommonNet.cpp" />
<ClCompile Include="..\libethereum\Defaults.cpp" />
<ClCompile Include="..\libethereum\DownloadMan.cpp" />
<ClCompile Include="..\libethereum\EthereumHost.cpp" />
<ClCompile Include="..\libethereum\EthereumPeer.cpp" />
<ClCompile Include="..\libethereum\Executive.cpp" />
@ -159,6 +172,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libp2p\_libp2p.cpp" />
<ClCompile Include="..\libwebthree\WebThree.cpp" />
<ClCompile Include="..\libwhisper\WhisperPeer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -223,6 +237,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\libdevcore\RangeMask.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\libdevcore\RLP.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -235,6 +255,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\libdevcore\Worker.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\libdevcrypto\All.h" />
<ClInclude Include="..\libdevcrypto\Common.h" />
<ClInclude Include="..\libdevcrypto\CryptoHeaders.h" />
@ -289,6 +315,7 @@
<ClInclude Include="..\libethereum\Client.h" />
<ClInclude Include="..\libethereum\CommonNet.h" />
<ClInclude Include="..\libethereum\Defaults.h" />
<ClInclude Include="..\libethereum\DownloadMan.h" />
<ClInclude Include="..\libethereum\EthereumHost.h" />
<ClInclude Include="..\libethereum\EthereumPeer.h" />
<ClInclude Include="..\libethereum\Executive.h" />
@ -376,6 +403,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\libwebthree\webthree.h" />
<ClInclude Include="..\libwhisper\Common.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

27
windows/LibEthereum.vcxproj.filters

@ -178,6 +178,18 @@
<ClCompile Include="..\libethereum\Manifest.cpp">
<Filter>libethereum</Filter>
</ClCompile>
<ClCompile Include="..\libdevcore\RangeMask.cpp">
<Filter>libdevcore</Filter>
</ClCompile>
<ClCompile Include="..\libdevcore\Worker.cpp">
<Filter>libdevcore</Filter>
</ClCompile>
<ClCompile Include="..\libethereum\DownloadMan.cpp">
<Filter>libethereum</Filter>
</ClCompile>
<ClCompile Include="..\libwebthree\WebThree.cpp">
<Filter>libwebthree</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -390,6 +402,18 @@
<ClInclude Include="..\libethereum\Manifest.h">
<Filter>libethereum</Filter>
</ClInclude>
<ClInclude Include="..\libdevcore\RangeMask.h">
<Filter>libdevcore</Filter>
</ClInclude>
<ClInclude Include="..\libdevcore\Worker.h">
<Filter>libdevcore</Filter>
</ClInclude>
<ClInclude Include="..\libethereum\DownloadMan.h">
<Filter>libethereum</Filter>
</ClInclude>
<ClInclude Include="..\libwebthree\webthree.h">
<Filter>libwebthree</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Windows">
@ -422,5 +446,8 @@
<Filter Include="libwhisper">
<UniqueIdentifier>{36748e80-c977-4fee-84e6-699c039dff87}</UniqueIdentifier>
</Filter>
<Filter Include="libwebthree">
<UniqueIdentifier>{d838fece-fc20-42f6-bff5-97c236159b80}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Loading…
Cancel
Save