Browse Source

Work in progress on Visual Studio 2013 compile fixes. Libethereum compiles again but not sorted out linking dependencies yet.

cl-refactor
Tim Hughes 11 years ago
parent
commit
21a840e20a
  1. 8
      eth/Ethereum.vcxproj
  2. 10
      eth/main.cpp
  3. 4
      libethereum/BlockChain.h
  4. 2
      libethereum/Client.h
  5. 12
      libethereum/Common.cpp
  6. 19
      libethereum/Common.h
  7. 2
      libethereum/FileSystem.cpp
  8. 5
      libethereum/LibEthereum.props
  9. 50
      libethereum/LibEthereum.vcxproj
  10. 44
      libethereum/LibEthereum.vcxproj.filters
  11. 14
      libethereum/PeerNetwork.cpp
  12. 18
      libethereum/PeerNetwork.h
  13. 10
      libethereum/RLP.cpp
  14. 4
      libethereum/RLP.h
  15. 13
      libethereum/State.cpp
  16. 6
      libethereum/TrieCommon.cpp
  17. 4
      libethereum/TrieCommon.h
  18. 6
      libethereum/TrieDB.h
  19. 16
      test/Test.vcxproj
  20. 8
      test/crypto.cpp
  21. 10
      test/dagger.cpp
  22. 2
      test/main.cpp
  23. 4
      test/peer.cpp
  24. 15
      test/trie.cpp

8
eth/Ethereum.vcxproj

@ -92,8 +92,6 @@
<AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
@ -111,8 +109,6 @@
<AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
@ -132,8 +128,6 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
@ -156,8 +150,6 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>

10
eth/main.cpp

@ -42,7 +42,7 @@ bytes contents(std::string const& _file)
return bytes(); return bytes();
// get length of file: // get length of file:
is.seekg (0, is.end); is.seekg (0, is.end);
int length = is.tellg(); streamoff length = is.tellg();
is.seekg (0, is.beg); is.seekg (0, is.beg);
bytes ret(length); bytes ret(length);
is.read((char*)ret.data(), length); is.read((char*)ret.data(), length);
@ -137,13 +137,13 @@ int main(int argc, char** argv)
{ {
string arg = argv[i]; string arg = argv[i];
if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc) if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
listenPort = atoi(argv[++i]); listenPort = (short)atoi(argv[++i]);
else if ((arg == "-u" || arg == "--public-ip" || arg == "--public") && i + 1 < argc) else if ((arg == "-u" || arg == "--public-ip" || arg == "--public") && i + 1 < argc)
publicIP = argv[++i]; publicIP = argv[++i];
else if ((arg == "-r" || arg == "--remote") && i + 1 < argc) else if ((arg == "-r" || arg == "--remote") && i + 1 < argc)
remoteHost = argv[++i]; remoteHost = argv[++i];
else if ((arg == "-p" || arg == "--port") && i + 1 < argc) else if ((arg == "-p" || arg == "--port") && i + 1 < argc)
remotePort = atoi(argv[++i]); remotePort = (short)atoi(argv[++i]);
else if ((arg == "-n" || arg == "--upnp") && i + 1 < argc) else if ((arg == "-n" || arg == "--upnp") && i + 1 < argc)
{ {
string m = argv[++i]; string m = argv[++i];
@ -226,14 +226,14 @@ int main(int argc, char** argv)
{ {
eth::uint port; eth::uint port;
cin >> port; cin >> port;
c.startNetwork(port); c.startNetwork((short)port);
} }
else if (cmd == "connect") else if (cmd == "connect")
{ {
string addr; string addr;
eth::uint port; eth::uint port;
cin >> addr >> port; cin >> addr >> port;
c.connect(addr, port); c.connect(addr, (short)port);
} }
else if (cmd == "netstop") else if (cmd == "netstop")
{ {

4
libethereum/BlockChain.h

@ -56,8 +56,8 @@ class Overlay;
class AlreadyHaveBlock: public std::exception {}; class AlreadyHaveBlock: public std::exception {};
class UnknownParent: public std::exception {}; class UnknownParent: public std::exception {};
struct BlockChainChat: public LogChannel { static const char constexpr* name = "-B-"; static const int verbosity = 7; }; struct BlockChainChat: public LogChannel { static const char* name() { return "-B-"; } static const int verbosity = 7; };
struct BlockChainNote: public LogChannel { static const char constexpr* name = "=B="; static const int verbosity = 4; }; struct BlockChainNote: public LogChannel { static const char* name() { return "=B="; } static const int verbosity = 4; };
/** /**
* @brief Implements the blockchain database. All data this gives is disk-backed. * @brief Implements the blockchain database. All data this gives is disk-backed.

2
libethereum/Client.h

@ -103,7 +103,7 @@ public:
/// Get information on the current peer set. /// Get information on the current peer set.
std::vector<PeerInfo> peers() { return m_net ? m_net->peers() : std::vector<PeerInfo>(); } std::vector<PeerInfo> peers() { return m_net ? m_net->peers() : std::vector<PeerInfo>(); }
/// Same as peers().size(), but more efficient. /// Same as peers().size(), but more efficient.
unsigned peerCount() const { return m_net ? m_net->peerCount() : 0; } size_t peerCount() const { return m_net ? m_net->peerCount() : 0; }
/// Start the network subsystem. /// Start the network subsystem.
void startNetwork(unsigned short _listenPort = 30303, std::string const& _seedHost = std::string(), unsigned short _port = 30303, NodeMode _mode = NodeMode::Full, unsigned _peers = 5, std::string const& _publicIP = std::string(), bool _upnp = true); void startNetwork(unsigned short _listenPort = 30303, std::string const& _seedHost = std::string(), unsigned short _port = 30303, NodeMode _mode = NodeMode::Full, unsigned _peers = 5, std::string const& _publicIP = std::string(), bool _upnp = true);

12
libethereum/Common.cpp

@ -36,7 +36,9 @@
#endif #endif
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
using namespace eth;
namespace eth
{
//#define ETH_ADDRESS_DEBUG 1 //#define ETH_ADDRESS_DEBUG 1
@ -191,13 +193,13 @@ KeyPair KeyPair::create()
{ {
secp256k1_start(); secp256k1_start();
static std::mt19937_64 s_eng(time(0)); static std::mt19937_64 s_eng(time(0));
std::uniform_int_distribution<byte> d(0, 255); std::uniform_int_distribution<uint16_t> d(0, 255);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
h256 sec; h256 sec;
for (uint i = 0; i < 32; ++i) for (unsigned i = 0; i < 32; ++i)
sec[i] = d(s_eng); sec[i] = (byte)d(s_eng);
KeyPair ret(sec); KeyPair ret(sec);
if (ret.address()) if (ret.address())
@ -281,3 +283,5 @@ std::string eth::formatBalance(u256 _b)
ret << _b << " wei"; ret << _b << " wei";
return ret.str(); return ret.str();
} }
}

19
libethereum/Common.h

@ -28,6 +28,11 @@
#pragma warning(disable:4244) #pragma warning(disable:4244)
#endif #endif
#ifdef _MSC_VER
#define _ALLOW_KEYWORD_MACROS
#define noexcept throw()
#endif
#include <ctime> #include <ctime>
#include <chrono> #include <chrono>
#include <array> #include <array>
@ -183,12 +188,12 @@ struct ThreadLocalLogName
extern ThreadLocalLogName t_logThreadName; extern ThreadLocalLogName t_logThreadName;
inline void setThreadName(char const* _n) { t_logThreadName.m_name.reset(new std::string(_n)); } inline void setThreadName(char const* _n) { t_logThreadName.m_name.reset(new std::string(_n)); }
struct LogChannel { static const char constexpr* name = " "; static const int verbosity = 1; }; struct LogChannel { static const char* name() { return " "; } static const int verbosity = 1; };
struct LeftChannel: public LogChannel { static const char constexpr* name = "<<<"; }; struct LeftChannel: public LogChannel { static const char* name() { return "<<<"; } };
struct RightChannel: public LogChannel { static const char constexpr* name = ">>>"; }; struct RightChannel: public LogChannel { static const char* name() { return ">>>"; } };
struct WarnChannel: public LogChannel { static const char constexpr* name = "!!!"; static const int verbosity = 0; }; struct WarnChannel: public LogChannel { static const char* name() { return "!!!"; } static const int verbosity = 0; };
struct NoteChannel: public LogChannel { static const char constexpr* name = "***"; }; struct NoteChannel: public LogChannel { static const char* name() { return "***"; } };
struct DebugChannel: public LogChannel { static const char constexpr* name = "---"; static const int verbosity = 7; }; struct DebugChannel: public LogChannel { static const char* name() { return "---"; } static const int verbosity = 0; };
extern int g_logVerbosity; extern int g_logVerbosity;
extern std::function<void(std::string const&, char const*)> g_logPost; extern std::function<void(std::string const&, char const*)> g_logPost;
@ -212,7 +217,7 @@ public:
sstr << Id::name << " [ " << buf << " | " << *(t_logThreadName.m_name.get()) << (_term ? " ] " : ""); sstr << Id::name << " [ " << buf << " | " << *(t_logThreadName.m_name.get()) << (_term ? " ] " : "");
} }
} }
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(sstr.str(), Id::name); } ~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(sstr.str(), Id::name()); }
template <class T> LogOutputStream& operator<<(T const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && sstr.str().size() && sstr.str().back() != ' ') sstr << " "; sstr << _t; } return *this; } template <class T> LogOutputStream& operator<<(T const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && sstr.str().size() && sstr.str().back() != ' ') sstr << " "; sstr << _t; } return *this; }
std::stringstream sstr; std::stringstream sstr;
}; };

2
libethereum/FileSystem.cpp

@ -39,7 +39,9 @@ std::string eth::getDataDir()
return (boost::filesystem::path(path) / "Ethereum").string(); return (boost::filesystem::path(path) / "Ethereum").string();
else else
{ {
#ifndef _MSC_VER // todo?
cwarn << "getDataDir(): SHGetSpecialFolderPathA() failed."; cwarn << "getDataDir(): SHGetSpecialFolderPathA() failed.";
#endif
throw std::runtime_error("getDataDir() - SHGetSpecialFolderPathA() failed."); throw std::runtime_error("getDataDir() - SHGetSpecialFolderPathA() failed.");
} }
#else #else

5
libethereum/LibEthereum.props

@ -3,7 +3,7 @@
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
<IncludePath>$(IncludePath);../../boost_1_55_0;../../leveldb-1.15.0/include;../../cryptopp562;../../secp256k1/include</IncludePath> <IncludePath>$(IncludePath);../../boost_1_55_0;../../leveldb/include;../../cryptopp562;../secp256k1</IncludePath>
<OutDir>..\build\$(ProjectName)\$(Platform)_$(Configuration)\</OutDir> <OutDir>..\build\$(ProjectName)\$(Platform)_$(Configuration)\</OutDir>
<IntDir>..\build\$(ProjectName)\$(Platform)_$(Configuration)\</IntDir> <IntDir>..\build\$(ProjectName)\$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup> </PropertyGroup>
@ -13,6 +13,9 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../..</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WIN32_WINNT=0x0501;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup /> <ItemGroup />

50
libethereum/LibEthereum.vcxproj

@ -18,35 +18,54 @@
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="AddressState.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="BlockChain.cpp" />
<ClCompile Include="BlockInfo.cpp" />
<ClCompile Include="Client.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="Dagger.cpp" />
<ClCompile Include="Defaults.cpp" />
<ClCompile Include="FileSystem.cpp" />
<ClCompile Include="MemTrie.cpp" />
<ClCompile Include="PeerNetwork.cpp" />
<ClCompile Include="RLP.cpp" />
<ClCompile Include="State.cpp" />
<ClCompile Include="Transaction.cpp" />
<ClCompile Include="TransactionQueue.cpp" />
<ClCompile Include="TrieCommon.cpp" />
<ClCompile Include="TrieDB.cpp" />
<ClCompile Include="TrieHash.cpp" />
<ClCompile Include="UPnP.cpp" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="AddressState.h" /> <ClInclude Include="AddressState.h" />
<ClInclude Include="BlockChain.h" /> <ClInclude Include="BlockChain.h" />
<ClInclude Include="BlockInfo.h" /> <ClInclude Include="BlockInfo.h" />
<ClInclude Include="Client.h" />
<ClInclude Include="Common.h" /> <ClInclude Include="Common.h" />
<ClInclude Include="Dagger.h" /> <ClInclude Include="Dagger.h" />
<ClInclude Include="Defaults.h" />
<ClInclude Include="Exceptions.h" /> <ClInclude Include="Exceptions.h" />
<ClInclude Include="FileSystem.h" />
<ClInclude Include="Instruction.h" /> <ClInclude Include="Instruction.h" />
<ClInclude Include="MemTrie.h" />
<ClInclude Include="PeerNetwork.h" /> <ClInclude Include="PeerNetwork.h" />
<ClInclude Include="RLP.h" /> <ClInclude Include="RLP.h" />
<ClInclude Include="State.h" /> <ClInclude Include="State.h" />
<ClInclude Include="Transaction.h" /> <ClInclude Include="Transaction.h" />
<ClInclude Include="TransactionQueue.h" /> <ClInclude Include="TransactionQueue.h" />
<ClInclude Include="Trie.h" /> <ClInclude Include="TrieCommon.h" />
<ClInclude Include="TrieDB.h" />
<ClInclude Include="TrieHash.h" />
<ClInclude Include="UPnP.h" />
<ClInclude Include="vector_ref.h" /> <ClInclude Include="vector_ref.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="AddressState.cpp" />
<ClCompile Include="BlockChain.cpp" />
<ClCompile Include="BlockInfo.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="Dagger.cpp" />
<ClCompile Include="PeerNetwork.cpp" />
<ClCompile Include="RLP.cpp" />
<ClCompile Include="State.cpp" />
<ClCompile Include="Transaction.cpp" />
<ClCompile Include="TransactionQueue.cpp" />
<ClCompile Include="Trie.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{7050C7CF-7551-48BE-8E57-92235906C13A}</ProjectGuid> <ProjectGuid>{7050C7CF-7551-48BE-8E57-92235906C13A}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
@ -128,7 +147,6 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
@ -136,6 +154,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<Lib />
<ProjectReference />
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>

44
libethereum/LibEthereum.vcxproj.filters

@ -1,32 +1,46 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClCompile Include="Transaction.cpp" />
<ClCompile Include="TransactionQueue.cpp" />
<ClCompile Include="TrieCommon.cpp" />
<ClCompile Include="TrieDB.cpp" />
<ClCompile Include="TrieHash.cpp" />
<ClCompile Include="UPnP.cpp" />
<ClCompile Include="AddressState.cpp" />
<ClCompile Include="BlockChain.cpp" />
<ClCompile Include="BlockInfo.cpp" />
<ClCompile Include="Client.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="Dagger.cpp" />
<ClCompile Include="Defaults.cpp" />
<ClCompile Include="FileSystem.cpp" />
<ClCompile Include="MemTrie.cpp" />
<ClCompile Include="PeerNetwork.cpp" />
<ClCompile Include="RLP.cpp" />
<ClCompile Include="State.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Transaction.h" />
<ClInclude Include="TransactionQueue.h" /> <ClInclude Include="TransactionQueue.h" />
<ClInclude Include="Trie.h" /> <ClInclude Include="TrieCommon.h" />
<ClInclude Include="TrieDB.h" />
<ClInclude Include="TrieHash.h" />
<ClInclude Include="UPnP.h" />
<ClInclude Include="vector_ref.h" /> <ClInclude Include="vector_ref.h" />
<ClInclude Include="AddressState.h" /> <ClInclude Include="AddressState.h" />
<ClInclude Include="BlockChain.h" /> <ClInclude Include="BlockChain.h" />
<ClInclude Include="BlockInfo.h" /> <ClInclude Include="BlockInfo.h" />
<ClInclude Include="Client.h" />
<ClInclude Include="Common.h" /> <ClInclude Include="Common.h" />
<ClInclude Include="Dagger.h" /> <ClInclude Include="Dagger.h" />
<ClInclude Include="Defaults.h" />
<ClInclude Include="Exceptions.h" /> <ClInclude Include="Exceptions.h" />
<ClInclude Include="FileSystem.h" />
<ClInclude Include="Instruction.h" /> <ClInclude Include="Instruction.h" />
<ClInclude Include="MemTrie.h" />
<ClInclude Include="PeerNetwork.h" /> <ClInclude Include="PeerNetwork.h" />
<ClInclude Include="RLP.h" /> <ClInclude Include="RLP.h" />
<ClInclude Include="State.h" /> <ClInclude Include="State.h" />
<ClInclude Include="Transaction.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Trie.cpp" />
<ClCompile Include="AddressState.cpp" />
<ClCompile Include="BlockChain.cpp" />
<ClCompile Include="BlockInfo.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="Dagger.cpp" />
<ClCompile Include="PeerNetwork.cpp" />
<ClCompile Include="RLP.cpp" />
<ClCompile Include="State.cpp" />
<ClCompile Include="Transaction.cpp" />
<ClCompile Include="TransactionQueue.cpp" />
</ItemGroup> </ItemGroup>
</Project> </Project>

14
libethereum/PeerNetwork.cpp

@ -170,12 +170,12 @@ bool PeerSession::interpret(RLP const& _r)
// Grab their block chain off them. // Grab their block chain off them.
{ {
clogS(NetAllDetail) << "Want chain. Latest:" << m_server->m_latestBlockSent << ", number:" << m_server->m_chain->details(m_server->m_latestBlockSent).number; clogS(NetAllDetail) << "Want chain. Latest:" << m_server->m_latestBlockSent << ", number:" << m_server->m_chain->details(m_server->m_latestBlockSent).number;
unsigned count = std::min<unsigned>(c_maxHashes, m_server->m_chain->details(m_server->m_latestBlockSent).number + 1); uint count = std::min(c_maxHashes, m_server->m_chain->details(m_server->m_latestBlockSent).number + 1);
RLPStream s; RLPStream s;
prep(s).appendList(2 + count); prep(s).appendList(2 + count);
s << GetChainPacket; s << GetChainPacket;
auto h = m_server->m_latestBlockSent; auto h = m_server->m_latestBlockSent;
for (unsigned i = 0; i < count; ++i, h = m_server->m_chain->details(h).parent) for (uint i = 0; i < count; ++i, h = m_server->m_chain->details(h).parent)
{ {
clogS(NetAllDetail) << " " << i << ":" << h; clogS(NetAllDetail) << " " << i << ":" << h;
s << h; s << h;
@ -407,12 +407,12 @@ bool PeerSession::interpret(RLP const& _r)
} }
else else
{ {
unsigned count = std::min<unsigned>(c_maxHashes, m_server->m_chain->details(noGood).number); uint count = std::min(c_maxHashes, m_server->m_chain->details(noGood).number);
RLPStream s; RLPStream s;
prep(s).appendList(2 + count); prep(s).appendList(2 + count);
s << GetChainPacket; s << GetChainPacket;
auto h = m_server->m_chain->details(noGood).parent; auto h = m_server->m_chain->details(noGood).parent;
for (unsigned i = 0; i < count; ++i, h = m_server->m_chain->details(h).parent) for (uint i = 0; i < count; ++i, h = m_server->m_chain->details(h).parent)
s << h; s << h;
s << c_maxBlocksAsk; s << c_maxBlocksAsk;
sealAndSend(s); sealAndSend(s);
@ -450,7 +450,7 @@ void PeerServer::seal(bytes& _b)
_b[1] = 0x40; _b[1] = 0x40;
_b[2] = 0x08; _b[2] = 0x08;
_b[3] = 0x91; _b[3] = 0x91;
uint32_t len = _b.size() - 8; uint32_t len = (uint32_t)_b.size() - 8;
_b[4] = (len >> 24) & 0xff; _b[4] = (len >> 24) & 0xff;
_b[5] = (len >> 16) & 0xff; _b[5] = (len >> 16) & 0xff;
_b[6] = (len >> 8) & 0xff; _b[6] = (len >> 8) & 0xff;
@ -698,10 +698,10 @@ void PeerServer::determinePublic(string const& _publicAddress, bool _upnp)
auto eip = m_upnp->externalIP(); auto eip = m_upnp->externalIP();
if (eip == string("0.0.0.0") && _publicAddress.empty()) if (eip == string("0.0.0.0") && _publicAddress.empty())
m_public = bi::tcp::endpoint(bi::address(), p); m_public = bi::tcp::endpoint(bi::address(), (unsigned short)p);
else else
{ {
m_public = bi::tcp::endpoint(bi::address::from_string(_publicAddress.empty() ? eip : _publicAddress), p); m_public = bi::tcp::endpoint(bi::address::from_string(_publicAddress.empty() ? eip : _publicAddress), (unsigned short)p);
m_addresses.push_back(m_public.address().to_v4()); m_addresses.push_back(m_public.address().to_v4());
} }
} }

18
libethereum/PeerNetwork.h

@ -40,13 +40,13 @@ bool isPrivateAddress(bi::address _addressToCheck);
class BlockChain; class BlockChain;
class TransactionQueue; class TransactionQueue;
struct NetWarn: public LogChannel { static const char constexpr* name = "!N!"; static const int verbosity = 0; }; struct NetWarn: public LogChannel { static const char* name() { return "!N!"; } static const int verbosity = 0; };
struct NetNote: public LogChannel { static const char constexpr* name = "*N*"; static const int verbosity = 1; }; struct NetNote: public LogChannel { static const char* name() { return "*N*"; } static const int verbosity = 1; };
struct NetMessageSummary: public LogChannel { static const char constexpr* name = "-N-"; static const int verbosity = 2; }; struct NetMessageSummary: public LogChannel { static const char* name() { return "-N-"; } static const int verbosity = 2; };
struct NetMessageDetail: public LogChannel { static const char constexpr* name = "=N="; static const int verbosity = 3; }; struct NetMessageDetail: public LogChannel { static const char* name() { return "=N="; } static const int verbosity = 3; };
struct NetAllDetail: public LogChannel { static const char constexpr* name = "=N="; static const int verbosity = 6; }; struct NetAllDetail: public LogChannel { static const char* name() { return "=N="; } static const int verbosity = 6; };
struct NetRight: public LogChannel { static const char constexpr* name = ">N>"; static const int verbosity = 8; }; struct NetRight: public LogChannel { static const char* name() { return ">N>"; } static const int verbosity = 8; };
struct NetLeft: public LogChannel { static const char constexpr* name = "<N<"; static const int verbosity = 9; }; struct NetLeft: public LogChannel { static const char* name() { return "<N<"; } static const int verbosity = 9; };
enum PacketType enum PacketType
{ {
@ -134,7 +134,7 @@ private:
std::chrono::steady_clock::time_point m_connect; std::chrono::steady_clock::time_point m_connect;
std::chrono::steady_clock::time_point m_disconnect; std::chrono::steady_clock::time_point m_disconnect;
unsigned m_rating; uint m_rating;
bool m_requireTransactions; bool m_requireTransactions;
std::set<h256> m_knownBlocks; std::set<h256> m_knownBlocks;
@ -182,7 +182,7 @@ public:
std::vector<PeerInfo> peers() const; std::vector<PeerInfo> peers() const;
/// Get number of peers connected; equivalent to, but faster than, peers().size(). /// Get number of peers connected; equivalent to, but faster than, peers().size().
unsigned peerCount() const { return m_peers.size(); } size_t peerCount() const { return m_peers.size(); }
/// Ping the peers, to update the latency information. /// Ping the peers, to update the latency information.
void pingAll(); void pingAll();

10
libethereum/RLP.cpp

@ -102,9 +102,9 @@ bool RLP::isInt() const
else if (n == c_rlpDataImmLenStart) else if (n == c_rlpDataImmLenStart)
return true; return true;
else if (n <= c_rlpDataIndLenZero) else if (n <= c_rlpDataIndLenZero)
return m_data[1]; return m_data[1] != 0;
else if (n < c_rlpListStart) else if (n < c_rlpListStart)
return m_data[1 + n - c_rlpDataIndLenZero]; return m_data[1 + n - c_rlpDataIndLenZero] != 0;
else else
return false; return false;
return false; return false;
@ -176,10 +176,10 @@ void RLPStream::noteAppended(uint _itemCount)
m_out.resize(os + encodeSize); m_out.resize(os + encodeSize);
memmove(m_out.data() + p + encodeSize, m_out.data() + p, os - p); memmove(m_out.data() + p + encodeSize, m_out.data() + p, os - p);
if (s < c_rlpListImmLenCount) if (s < c_rlpListImmLenCount)
m_out[p] = c_rlpListStart + s; m_out[p] = (byte)(c_rlpListStart + s);
else else
{ {
m_out[p] = c_rlpListIndLenZero + brs; m_out[p] = (byte)(c_rlpListIndLenZero + brs);
byte* b = &(m_out[p + brs]); byte* b = &(m_out[p + brs]);
for (; s; s >>= 8) for (; s; s >>= 8)
*(b--) = (byte)s; *(b--) = (byte)s;
@ -189,7 +189,7 @@ void RLPStream::noteAppended(uint _itemCount)
} }
} }
RLPStream& RLPStream::appendList(unsigned _items) RLPStream& RLPStream::appendList(uint _items)
{ {
// cdebug << "appendList(" << _items << ")"; // cdebug << "appendList(" << _items << ")";
if (_items) if (_items)

4
libethereum/RLP.h

@ -175,7 +175,7 @@ public:
std::string toStringStrict() const { if (!isData()) throw BadCast(); return payload().cropped(0, length()).toString(); } std::string toStringStrict() const { if (!isData()) throw BadCast(); return payload().cropped(0, length()).toString(); }
template <class T> std::vector<T> toVector() const { std::vector<T> ret; if (isList()) { ret.reserve(itemCount()); for (auto const& i: *this) ret.push_back((T)i); } return ret; } template <class T> std::vector<T> toVector() const { std::vector<T> ret; if (isList()) { ret.reserve(itemCount()); for (auto const& i: *this) ret.push_back((T)i); } return ret; }
template <class T, size_t N> std::array<T, N> toArray() const { std::array<T, N> ret; if (itemCount() != N) throw BadCast(); if (isList()) for (uint i = 0; i < N; ++i) ret[i] = (T)operator[](i); return ret; } template <class T, size_t N> std::array<T, N> toArray() const { if (itemCount() != N || !isList()) throw BadCast(); std::array<T, N> ret; for (uint i = 0; i < N; ++i) ret[i] = (T)operator[](i); return ret; }
/// Int conversion flags /// Int conversion flags
enum enum
@ -288,7 +288,7 @@ public:
template <class _T, size_t S> RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } template <class _T, size_t S> RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; }
/// Appends a list. /// Appends a list.
RLPStream& appendList(unsigned _items); RLPStream& appendList(uint _items);
RLPStream& appendList(bytesConstRef _rlp); RLPStream& appendList(bytesConstRef _rlp);
RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); } RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); }
RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); } RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); }

13
libethereum/State.cpp

@ -44,7 +44,8 @@
#include "Dagger.h" #include "Dagger.h"
#include "Defaults.h" #include "Defaults.h"
using namespace std; using namespace std;
using namespace eth;
namespace eth {
u256 const c_stepFee = 1; u256 const c_stepFee = 1;
u256 const c_dataFee = 20; u256 const c_dataFee = 20;
@ -286,7 +287,9 @@ bool State::cull(TransactionQueue& _tq) const
bool ret = false; bool ret = false;
auto ts = _tq.transactions(); auto ts = _tq.transactions();
for (auto const& i: ts) for (auto const& i: ts)
{
if (!m_transactions.count(i.first)) if (!m_transactions.count(i.first))
{
try try
{ {
Transaction t(i.second); Transaction t(i.second);
@ -301,6 +304,8 @@ bool State::cull(TransactionQueue& _tq) const
_tq.drop(i.first); _tq.drop(i.first);
ret = true; ret = true;
} }
}
}
return ret; return ret;
} }
@ -310,7 +315,9 @@ bool State::sync(TransactionQueue& _tq)
bool ret = false; bool ret = false;
auto ts = _tq.transactions(); auto ts = _tq.transactions();
for (auto const& i: ts) for (auto const& i: ts)
{
if (!m_transactions.count(i.first)) if (!m_transactions.count(i.first))
{
// don't have it yet! Execute it now. // don't have it yet! Execute it now.
try try
{ {
@ -332,6 +339,8 @@ bool State::sync(TransactionQueue& _tq)
_tq.drop(i.first); _tq.drop(i.first);
ret = true; ret = true;
} }
}
}
return ret; return ret;
} }
@ -1233,3 +1242,5 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256s
} }
} }
} }
}

6
libethereum/TrieCommon.cpp

@ -110,14 +110,14 @@ std::string hexPrefixEncode(bytesConstRef _d1, uint _o1, bytesConstRef _d2, uint
return ret; return ret;
} }
byte uniqueInUse(RLP const& _orig, byte _except) byte uniqueInUse(RLP const& _orig, byte except)
{ {
byte used = 255; byte used = 255;
for (unsigned i = 0; i < 17; ++i) for (unsigned i = 0; i < 17; ++i)
if (i != _except && !_orig[i].isEmpty()) if (i != except && !_orig[i].isEmpty())
{ {
if (used == 255) if (used == 255)
used = i; used = (byte)i;
else else
return 255; return 255;
} }

4
libethereum/TrieCommon.h

@ -66,7 +66,7 @@ inline bool isLeaf(RLP const& _twoItem)
{ {
assert(_twoItem.isList() && _twoItem.itemCount() == 2); assert(_twoItem.isList() && _twoItem.itemCount() == 2);
auto pl = _twoItem[0].payload(); auto pl = _twoItem[0].payload();
return (pl[0] & 0x20); return (pl[0] & 0x20) != 0;
} }
inline NibbleSlice keyOf(bytesConstRef _hpe) inline NibbleSlice keyOf(bytesConstRef _hpe)
@ -84,7 +84,7 @@ inline NibbleSlice keyOf(RLP const& _twoItem)
return keyOf(_twoItem[0].payload()); return keyOf(_twoItem[0].payload());
} }
byte uniqueInUse(RLP const& _orig, byte _except); byte uniqueInUse(RLP const& _orig, byte except);
std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf = false, int _begin = 0, int _end = -1); std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf = false, int _begin = 0, int _end = -1);
std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, uint _offset); std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, uint _offset);
std::string hexPrefixEncode(bytesConstRef _d1, uint _o1, bytesConstRef _d2, uint _o2, bool _leaf); std::string hexPrefixEncode(bytesConstRef _d1, uint _o1, bytesConstRef _d2, uint _o2, bool _leaf);

6
libethereum/TrieDB.h

@ -131,7 +131,7 @@ public:
iterator(GenericTrieDB const* _db) iterator(GenericTrieDB const* _db)
{ {
m_that = _db; m_that = _db;
m_trail.push_back(Node{_db->node(_db->m_root), std::string(1, '\0'), 255}); // one null byte is the HPE for the empty key. m_trail.push_back({_db->node(_db->m_root), std::string(1, '\0'), 255}); // one null byte is the HPE for the empty key.
next(); next();
} }
@ -727,10 +727,10 @@ template <class DB> bytes GenericTrieDB<DB>::cleve(RLP const& _orig, uint _s)
assert(_s && _s <= k.size()); assert(_s && _s <= k.size());
RLPStream bottom(2); RLPStream bottom(2);
bottom << hexPrefixEncode(k, isLeaf(_orig), _s) << _orig[1]; bottom << hexPrefixEncode(k, isLeaf(_orig), /*ugh*/(int)_s) << _orig[1];
RLPStream top(2); RLPStream top(2);
top << hexPrefixEncode(k, false, 0, _s); top << hexPrefixEncode(k, false, 0, /*ugh*/(int)_s);
streamNode(top, bottom.out()); streamNode(top, bottom.out());
return top.out(); return top.out();

16
test/Test.vcxproj

@ -92,7 +92,6 @@
<AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport> <OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
@ -100,6 +99,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<LargeAddressAware>true</LargeAddressAware> <LargeAddressAware>true</LargeAddressAware>
<AdditionalLibraryDirectories>../../boost_1_55_0/stage/x86</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -111,13 +111,12 @@
<AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../libethereum</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>../../boost_1_55_0/stage/x64</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -132,7 +131,6 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport> <OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
@ -142,6 +140,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<LargeAddressAware>true</LargeAddressAware> <LargeAddressAware>true</LargeAddressAware>
<AdditionalLibraryDirectories>../../boost_1_55_0/stage/x86</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -156,7 +155,6 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>true</OpenMPSupport> <OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>4351</DisableSpecificWarnings> <DisableSpecificWarnings>4351</DisableSpecificWarnings>
</ClCompile> </ClCompile>
@ -165,6 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>../../boost_1_55_0/stage/x64</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
@ -176,7 +175,14 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="crypto.cpp" />
<ClCompile Include="dagger.cpp" />
<ClCompile Include="hexPrefix.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="peer.cpp" />
<ClCompile Include="rlp.cpp" />
<ClCompile Include="state.cpp" />
<ClCompile Include="trie.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

8
test/crypto.cpp

@ -87,7 +87,7 @@ int cryptoTest()
ret = secp256k1_ecdsa_pubkey_create(pubkey.data(), &pubkeylen, privkey.data(), 1); ret = secp256k1_ecdsa_pubkey_create(pubkey.data(), &pubkeylen, privkey.data(), 1);
pubkey.resize(pubkeylen); pubkey.resize(pubkeylen);
int good = secp256k1_ecdsa_pubkey_verify(pubkey.data(), pubkey.size()); int good = secp256k1_ecdsa_pubkey_verify(pubkey.data(), (int)pubkey.size());
cout << "PUB: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << (good ? " GOOD" : " BAD") << endl; cout << "PUB: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << (good ? " GOOD" : " BAD") << endl;
} }
@ -99,12 +99,12 @@ int cryptoTest()
cout << asHex(hmsg) << endl; cout << asHex(hmsg) << endl;
cout << asHex(privkey) << endl; cout << asHex(privkey) << endl;
cout << hex << nonce << dec << endl; cout << hex << nonce << dec << endl;
int ret = secp256k1_ecdsa_sign_compact((byte const*)hmsg.data(), hmsg.size(), sig.data(), privkey.data(), (byte const*)&nonce, &v); int ret = secp256k1_ecdsa_sign_compact((byte const*)hmsg.data(), (int)hmsg.size(), sig.data(), privkey.data(), (byte const*)&nonce, &v);
cout << "MYSIG: " << dec << ret << " " << sig.size() << " " << asHex(sig) << " " << v << endl; cout << "MYSIG: " << dec << ret << " " << sig.size() << " " << asHex(sig) << " " << v << endl;
bytes pubkey(65); bytes pubkey(65);
int pubkeylen = 65; int pubkeylen = 65;
ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), hmsg.size(), (byte const*)sig.data(), pubkey.data(), &pubkeylen, 0, v); ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig.data(), pubkey.data(), &pubkeylen, 0, v);
pubkey.resize(pubkeylen); pubkey.resize(pubkeylen);
cout << "MYREC: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << endl; cout << "MYREC: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << endl;
} }
@ -112,7 +112,7 @@ int cryptoTest()
{ {
bytes pubkey(65); bytes pubkey(65);
int pubkeylen = 65; int pubkeylen = 65;
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27); int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
pubkey.resize(pubkeylen); pubkey.resize(pubkeylen);
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << endl; cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << asHex(pubkey) << endl;
cout << "SENDER: " << hex << low160(eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl; cout << "SENDER: " << hex << low160(eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;

10
test/dagger.cpp

@ -30,19 +30,17 @@ int daggerTest()
{ {
// Test dagger // Test dagger
{ {
Dagger d;
auto s = steady_clock::now(); auto s = steady_clock::now();
cout << hex << d.eval((h256)1, (h256)0); cout << hex << Dagger().eval((h256)1, (h256)0);
cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl; cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl;
cout << hex << d.eval((h256)1, (h256)1); cout << hex << Dagger().eval((h256)1, (h256)1);
cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl; cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl;
} }
{ {
Dagger d;
auto s = steady_clock::now(); auto s = steady_clock::now();
cout << hex << d.eval((h256)1, (h256)0); cout << hex << Dagger().eval((h256)1, (h256)0);
cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl; cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl;
cout << hex << d.eval((h256)1, (h256)1); cout << hex << Dagger().eval((h256)1, (h256)1);
cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl; cout << " " << dec << duration_cast<milliseconds>(steady_clock::now() - s).count() << " ms" << endl;
} }
return 0; return 0;

2
test/main.cpp

@ -34,7 +34,7 @@ int peerTest(int argc, char** argv);
#include <BlockInfo.h> #include <BlockInfo.h>
using namespace eth; using namespace eth;
int main(int argc, char** argv) int main(int, char**)
{ {
/* RLPStream s; /* RLPStream s;
BlockInfo::genesis().fillStream(s, false); BlockInfo::genesis().fillStream(s, false);

4
test/peer.cpp

@ -38,11 +38,11 @@ int peerTest(int argc, char** argv)
{ {
string arg = argv[i]; string arg = argv[i];
if (arg == "-l" && i + 1 < argc) if (arg == "-l" && i + 1 < argc)
listenPort = atoi(argv[++i]); listenPort = (short)atoi(argv[++i]);
else if (arg == "-r" && i + 1 < argc) else if (arg == "-r" && i + 1 < argc)
remoteHost = argv[++i]; remoteHost = argv[++i];
else if (arg == "-p" && i + 1 < argc) else if (arg == "-p" && i + 1 < argc)
remotePort = atoi(argv[++i]); remotePort = (short)atoi(argv[++i]);
else else
remoteHost = argv[i]; remoteHost = argv[i];
} }

15
test/trie.cpp

@ -27,6 +27,11 @@
using namespace std; using namespace std;
using namespace eth; using namespace eth;
inline h256 stringMapHash256(StringMap const& _s)
{
return hash256(_s);
}
int trieTest() int trieTest()
{ {
{ {
@ -42,13 +47,13 @@ int trieTest()
cout << t; cout << t;
cout << m; cout << m;
cout << t.root() << endl; cout << t.root() << endl;
cout << hash256({{"test", "test"}}) << endl; cout << stringMapHash256({{"test", "test"}}) << endl;
t.insert(string("tesa"), string("testy")); t.insert(string("tesa"), string("testy"));
cout << t; cout << t;
cout << m; cout << m;
cout << t.root() << endl; cout << t.root() << endl;
cout << hash256({{"test", "test"}, {"te", "testy"}}) << endl; cout << stringMapHash256({{"test", "test"}, {"te", "testy"}}) << endl;
cout << t.at(string("test")) << endl; cout << t.at(string("test")) << endl;
cout << t.at(string("te")) << endl; cout << t.at(string("te")) << endl;
cout << t.at(string("t")) << endl; cout << t.at(string("t")) << endl;
@ -56,7 +61,7 @@ int trieTest()
t.remove(string("te")); t.remove(string("te"));
cout << m; cout << m;
cout << t.root() << endl; cout << t.root() << endl;
cout << hash256({{"test", "test"}}) << endl; cout << stringMapHash256({{"test", "test"}}) << endl;
t.remove(string("test")); t.remove(string("test"));
cout << m; cout << m;
@ -72,7 +77,7 @@ int trieTest()
cout << t; cout << t;
cout << m; cout << m;
cout << t.root() << endl; cout << t.root() << endl;
cout << hash256({{"b", "B"}, {"a", "A"}}) << endl; cout << stringMapHash256({{"b", "B"}, {"a", "A"}}) << endl;
cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl; cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl;
} }
{ {
@ -89,7 +94,7 @@ int trieTest()
cout << RLP(t.rlp()) << endl; cout << RLP(t.rlp()) << endl;
} }
{ {
cout << hex << hash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl; cout << hex << stringMapHash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl;
MemTrie t; MemTrie t;
t.insert("dog", "puppy"); t.insert("dog", "puppy");
t.insert("doe", "reindeer"); t.insert("doe", "reindeer");

Loading…
Cancel
Save