Add ripple_basics unity build module

This commit is contained in:
Vinnie Falco
2013-05-22 15:09:20 -07:00
parent 0159acbf5a
commit b9aa8e0a84
11 changed files with 328 additions and 202 deletions

View File

@@ -24,4 +24,52 @@
#include "ripple_basics.h" #include "ripple_basics.h"
//#include "src/cpp/ripple/Amount.cpp" // VFALCO: TODO, clean this up
// This is here for Amount*.cpp
#include "src/cpp/ripple/bignum.h"
#if (ULONG_MAX > UINT_MAX)
#define BN_add_word64(bn, word) BN_add_word(bn, word)
#define BN_sub_word64(bn, word) BN_sub_word(bn, word)
#define BN_mul_word64(bn, word) BN_mul_word(bn, word)
#define BN_div_word64(bn, word) BN_div_word(bn, word)
#else
#include "src/cpp/ripple/BigNum64.h"
#endif
static const uint64 tenTo14 = 100000000000000ull;
static const uint64 tenTo14m1 = tenTo14 - 1;
static const uint64 tenTo17 = tenTo14 * 1000;
static const uint64 tenTo17m1 = tenTo17 - 1;
// VFALCO: TODO, fix these warnings!
#ifdef _MSC_VER
//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length"
#pragma warning (disable: 4018) // signed/unsigned mismatch
#pragma warning (disable: 4244) // conversion, possible loss of data
#endif
#include "src/cpp/ripple/Log.cpp"
#include "src/cpp/ripple/Amount.cpp"
#include "src/cpp/ripple/AmountRound.cpp"
#include "src/cpp/ripple/BitcoinUtil.cpp" // no log
#include "src/cpp/ripple/DeterministicKeys.cpp"
#include "src/cpp/ripple/ECIES.cpp" // no log
#include "src/cpp/ripple/FieldNames.cpp" // no log
#include "src/cpp/ripple/HashedObject.cpp"
#include "src/cpp/ripple/PackedMessage.cpp" // no log
#include "src/cpp/ripple/ParameterTable.cpp" // no log
#include "src/cpp/ripple/ParseSection.cpp"
#include "src/cpp/ripple/PlatRand.cpp" // no log
#include "src/cpp/ripple/ProofOfWork.cpp"
#include "src/cpp/ripple/RangeSet.cpp"
#include "src/cpp/ripple/rfc1751.cpp" // no log
#include "src/cpp/ripple/SHAMap.cpp"
#include "src/cpp/ripple/SHAMapDiff.cpp" // no log
#include "src/cpp/ripple/SHAMapNodes.cpp" // no log
#include "src/cpp/ripple/SHAMapSync.cpp"
#include "src/cpp/ripple/utils.cpp" // no log
#ifdef _MSC_VER
//#pragma warning (pop)
#endif

View File

@@ -535,10 +535,25 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\Amount.cpp" /> <ClCompile Include="src\cpp\ripple\Amount.cpp">
<ClCompile Include="src\cpp\ripple\AmountRound.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="src\cpp\ripple\AmountRound.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="src\cpp\ripple\Application.cpp" /> <ClCompile Include="src\cpp\ripple\Application.cpp" />
<ClCompile Include="src\cpp\ripple\BitcoinUtil.cpp" /> <ClCompile Include="src\cpp\ripple\BitcoinUtil.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="src\cpp\ripple\CallRPC.cpp"> <ClCompile Include="src\cpp\ripple\CallRPC.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -566,16 +581,36 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\DBInit.cpp" /> <ClCompile Include="src\cpp\ripple\DBInit.cpp" />
<ClCompile Include="src\cpp\ripple\DeterministicKeys.cpp" /> <ClCompile Include="src\cpp\ripple\DeterministicKeys.cpp">
<ClCompile Include="src\cpp\ripple\ECIES.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="src\cpp\ripple\ECIES.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="src\cpp\ripple\FeatureTable.cpp"> <ClCompile Include="src\cpp\ripple\FeatureTable.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\FieldNames.cpp" /> <ClCompile Include="src\cpp\ripple\FieldNames.cpp">
<ClCompile Include="src\cpp\ripple\HashedObject.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="src\cpp\ripple\HashedObject.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="src\cpp\ripple\HTTPRequest.cpp" /> <ClCompile Include="src\cpp\ripple\HTTPRequest.cpp" />
<ClCompile Include="src\cpp\ripple\HttpsClient.cpp"> <ClCompile Include="src\cpp\ripple\HttpsClient.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -642,7 +677,12 @@
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\LoadManager.cpp" /> <ClCompile Include="src\cpp\ripple\LoadManager.cpp" />
<ClCompile Include="src\cpp\ripple\LoadMonitor.cpp" /> <ClCompile Include="src\cpp\ripple\LoadMonitor.cpp" />
<ClCompile Include="src\cpp\ripple\Log.cpp" /> <ClCompile Include="src\cpp\ripple\Log.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="src\cpp\ripple\main.cpp" /> <ClCompile Include="src\cpp\ripple\main.cpp" />
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp" /> <ClCompile Include="src\cpp\ripple\NetworkOPs.cpp" />
<ClCompile Include="src\cpp\ripple\NicknameState.cpp" /> <ClCompile Include="src\cpp\ripple\NicknameState.cpp" />
@@ -682,9 +722,24 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\PackedMessage.cpp" /> <ClCompile Include="src\cpp\ripple\PackedMessage.cpp">
<ClCompile Include="src\cpp\ripple\ParameterTable.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ClCompile Include="src\cpp\ripple\ParseSection.cpp" /> <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="src\cpp\ripple\ParameterTable.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="src\cpp\ripple\ParseSection.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="src\cpp\ripple\PathDB.cpp" /> <ClCompile Include="src\cpp\ripple\PathDB.cpp" />
<ClCompile Include="src\cpp\ripple\Pathfinder.cpp" /> <ClCompile Include="src\cpp\ripple\Pathfinder.cpp" />
<ClCompile Include="src\cpp\ripple\PaymentTransactor.cpp"> <ClCompile Include="src\cpp\ripple\PaymentTransactor.cpp">
@@ -696,16 +751,36 @@
<ClCompile Include="src\cpp\ripple\Peer.cpp" /> <ClCompile Include="src\cpp\ripple\Peer.cpp" />
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp" /> <ClCompile Include="src\cpp\ripple\PeerDoor.cpp" />
<ClCompile Include="src\cpp\ripple\PFRequest.cpp" /> <ClCompile Include="src\cpp\ripple\PFRequest.cpp" />
<ClCompile Include="src\cpp\ripple\PlatRand.cpp" /> <ClCompile Include="src\cpp\ripple\PlatRand.cpp">
<ClCompile Include="src\cpp\ripple\ProofOfWork.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ClCompile Include="src\cpp\ripple\RangeSet.cpp" /> <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="src\cpp\ripple\ProofOfWork.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="src\cpp\ripple\RangeSet.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="src\cpp\ripple\RegularKeySetTransactor.cpp"> <ClCompile Include="src\cpp\ripple\RegularKeySetTransactor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\rfc1751.cpp" /> <ClCompile Include="src\cpp\ripple\rfc1751.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="src\cpp\ripple\ripple.pb.cc" /> <ClCompile Include="src\cpp\ripple\ripple.pb.cc" />
<ClCompile Include="src\cpp\ripple\RippleAddress.cpp" /> <ClCompile Include="src\cpp\ripple\RippleAddress.cpp" />
<ClCompile Include="src\cpp\ripple\RippleCalc.cpp"> <ClCompile Include="src\cpp\ripple\RippleCalc.cpp">
@@ -793,10 +868,30 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\SHAMap.cpp" /> <ClCompile Include="src\cpp\ripple\SHAMap.cpp">
<ClCompile Include="src\cpp\ripple\SHAMapDiff.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ClCompile Include="src\cpp\ripple\SHAMapNodes.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ClCompile Include="src\cpp\ripple\SHAMapSync.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\SHAMapDiff.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="src\cpp\ripple\SHAMapNodes.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="src\cpp\ripple\SHAMapSync.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="src\cpp\ripple\SNTPClient.cpp" /> <ClCompile Include="src\cpp\ripple\SNTPClient.cpp" />
<ClCompile Include="src\cpp\ripple\Suppression.cpp" /> <ClCompile Include="src\cpp\ripple\Suppression.cpp" />
<ClCompile Include="src\cpp\ripple\Transaction.cpp"> <ClCompile Include="src\cpp\ripple\Transaction.cpp">

View File

@@ -14,11 +14,9 @@
#include "SerializedTypes.h" #include "SerializedTypes.h"
#include "utils.h" #include "utils.h"
SETUP_LOG();
uint64 STAmount::uRateOne = STAmount::getRate(STAmount(1), STAmount(1)); uint64 STAmount::uRateOne = STAmount::getRate(STAmount(1), STAmount(1));
static const uint64 tenTo14 = 100000000000000ull;
static const uint64 tenTo17 = tenTo14 * 1000;
#if (ULONG_MAX > UINT_MAX) #if (ULONG_MAX > UINT_MAX)
#define BN_add_word64(bn, word) BN_add_word(bn, word) #define BN_add_word64(bn, word) BN_add_word(bn, word)
@@ -107,7 +105,7 @@ bool STAmount::bSetJson(const Json::Value& jvSource)
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
cLog(lsINFO) WriteLog (lsINFO, STAmount)
<< boost::str(boost::format("bSetJson(): caught: %s") << boost::str(boost::format("bSetJson(): caught: %s")
% e.what()); % e.what());
@@ -122,7 +120,7 @@ STAmount::STAmount(SField::ref n, const Json::Value& v)
if (v.isObject()) if (v.isObject())
{ {
cLog(lsTRACE) WriteLog (lsTRACE, STAmount)
<< boost::str(boost::format("value='%s', currency='%s', issuer='%s'") << boost::str(boost::format("value='%s', currency='%s', issuer='%s'")
% v["value"].asString() % v["value"].asString()
% v["currency"].asString() % v["currency"].asString()
@@ -272,7 +270,7 @@ bool STAmount::setValue(const std::string& sAmount)
if (!boost::regex_match(sAmount, smMatch, reNumber)) if (!boost::regex_match(sAmount, smMatch, reNumber))
{ {
cLog(lsWARNING) << "Number not valid: \"" << sAmount << "\""; WriteLog (lsWARNING, STAmount) << "Number not valid: \"" << sAmount << "\"";
return false; return false;
} }
@@ -283,7 +281,7 @@ bool STAmount::setValue(const std::string& sAmount)
{ {
if ((smMatch[2].length() + smMatch[4].length()) > 32) if ((smMatch[2].length() + smMatch[4].length()) > 32)
{ {
cLog(lsWARNING) << "Overlong number: " << sAmount; WriteLog (lsWARNING, STAmount) << "Overlong number: " << sAmount;
return false; return false;
} }
@@ -310,11 +308,11 @@ bool STAmount::setValue(const std::string& sAmount)
} }
catch (...) catch (...)
{ {
cLog(lsWARNING) << "Number not parsed: \"" << sAmount << "\""; WriteLog (lsWARNING, STAmount) << "Number not parsed: \"" << sAmount << "\"";
return false; return false;
} }
cLog(lsTRACE) << "Float \"" << sAmount << "\" parsed to " << mValue << " : " << mOffset; WriteLog (lsTRACE, STAmount) << "Float \"" << sAmount << "\" parsed to " << mValue << " : " << mOffset;
if (mIsNative) if (mIsNative)
{ {
@@ -351,7 +349,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
// //
if (!currencyFromString(mCurrency, sCurrency)) if (!currencyFromString(mCurrency, sCurrency))
{ {
cLog(lsINFO) << "Currency malformed: " << sCurrency; WriteLog (lsINFO, STAmount) << "Currency malformed: " << sCurrency;
return false; return false;
} }
@@ -366,7 +364,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
// Issuer must be "" or a valid account string. // Issuer must be "" or a valid account string.
if (!naIssuerID.setAccountID(sIssuer)) if (!naIssuerID.setAccountID(sIssuer))
{ {
cLog(lsINFO) << "Issuer malformed: " << sIssuer; WriteLog (lsINFO, STAmount) << "Issuer malformed: " << sIssuer;
return false; return false;
} }
@@ -376,7 +374,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
// Stamps not must have an issuer. // Stamps not must have an issuer.
if (mIsNative && !mIssuer.isZero()) if (mIsNative && !mIssuer.isZero())
{ {
cLog(lsINFO) << "Issuer specified for XRP: " << sIssuer; WriteLog (lsINFO, STAmount) << "Issuer specified for XRP: " << sIssuer;
return false; return false;
} }
@@ -1034,17 +1032,17 @@ bool STAmount::applyOffer(
? saOfferFunds // As is. ? saOfferFunds // As is.
: STAmount::divide(saOfferFunds, STAmount(CURRENCY_ONE, ACCOUNT_ONE, uOfferPaysRate, -9)); // Reduce by offer fees. : STAmount::divide(saOfferFunds, STAmount(CURRENCY_ONE, ACCOUNT_ONE, uOfferPaysRate, -9)); // Reduce by offer fees.
cLog(lsINFO) << "applyOffer: uOfferPaysRate=" << uOfferPaysRate; WriteLog (lsINFO, STAmount) << "applyOffer: uOfferPaysRate=" << uOfferPaysRate;
cLog(lsINFO) << "applyOffer: saOfferFundsAvailable=" << saOfferFundsAvailable.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saOfferFundsAvailable=" << saOfferFundsAvailable.getFullText();
// Limit taker funds available, by transfer fees. // Limit taker funds available, by transfer fees.
STAmount saTakerFundsAvailable = QUALITY_ONE == uTakerPaysRate STAmount saTakerFundsAvailable = QUALITY_ONE == uTakerPaysRate
? saTakerFunds // As is. ? saTakerFunds // As is.
: STAmount::divide(saTakerFunds, STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9)); // Reduce by taker fees. : STAmount::divide(saTakerFunds, STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9)); // Reduce by taker fees.
cLog(lsINFO) << "applyOffer: TAKER_FEES=" << STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9).getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: TAKER_FEES=" << STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9).getFullText();
cLog(lsINFO) << "applyOffer: uTakerPaysRate=" << uTakerPaysRate; WriteLog (lsINFO, STAmount) << "applyOffer: uTakerPaysRate=" << uTakerPaysRate;
cLog(lsINFO) << "applyOffer: saTakerFundsAvailable=" << saTakerFundsAvailable.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerFundsAvailable=" << saTakerFundsAvailable.getFullText();
STAmount saOfferPaysAvailable; // Amount offer can pay out, limited by offer and offerer funds. STAmount saOfferPaysAvailable; // Amount offer can pay out, limited by offer and offerer funds.
STAmount saOfferGetsAvailable; // Amount offer would get, limited by offer funds. STAmount saOfferGetsAvailable; // Amount offer would get, limited by offer funds.
@@ -1064,24 +1062,24 @@ bool STAmount::applyOffer(
saOfferGetsAvailable = std::min(saOfferGets, mulRound(saOfferPaysAvailable, saOfferRate, saOfferGets, true)); saOfferGetsAvailable = std::min(saOfferGets, mulRound(saOfferPaysAvailable, saOfferRate, saOfferGets, true));
} }
cLog(lsINFO) << "applyOffer: saOfferPaysAvailable=" << saOfferFundsAvailable.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saOfferPaysAvailable=" << saOfferFundsAvailable.getFullText();
cLog(lsINFO) << "applyOffer: saOfferGetsAvailable=" << saOfferGetsAvailable.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saOfferGetsAvailable=" << saOfferGetsAvailable.getFullText();
STAmount saTakerPaysAvailable = std::min(saTakerPays, saTakerFundsAvailable); STAmount saTakerPaysAvailable = std::min(saTakerPays, saTakerFundsAvailable);
cLog(lsINFO) << "applyOffer: saTakerPaysAvailable=" << saTakerPaysAvailable.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerPaysAvailable=" << saTakerPaysAvailable.getFullText();
// Limited = limited by other sides raw numbers. // Limited = limited by other sides raw numbers.
// Taker can't pay more to offer than offer can get. // Taker can't pay more to offer than offer can get.
STAmount saTakerPaysLimited = std::min(saTakerPaysAvailable, saOfferGetsAvailable); STAmount saTakerPaysLimited = std::min(saTakerPaysAvailable, saOfferGetsAvailable);
cLog(lsINFO) << "applyOffer: saTakerPaysLimited=" << saTakerPaysLimited.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerPaysLimited=" << saTakerPaysLimited.getFullText();
// Align saTakerGetsLimited with saTakerPaysLimited. // Align saTakerGetsLimited with saTakerPaysLimited.
STAmount saTakerGetsLimited = saTakerPaysLimited >= saOfferGetsAvailable STAmount saTakerGetsLimited = saTakerPaysLimited >= saOfferGetsAvailable
? saOfferPaysAvailable // Potentially take entire offer. Avoid math shenanigans. ? saOfferPaysAvailable // Potentially take entire offer. Avoid math shenanigans.
: std::min(saOfferPaysAvailable, divRound(saTakerPaysLimited, saOfferRate, saTakerGets, true)); // Taker a portion of offer. : std::min(saOfferPaysAvailable, divRound(saTakerPaysLimited, saOfferRate, saTakerGets, true)); // Taker a portion of offer.
cLog(lsINFO) << "applyOffer: saOfferRate=" << saOfferRate.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saOfferRate=" << saOfferRate.getFullText();
cLog(lsINFO) << "applyOffer: saTakerGetsLimited=" << saTakerGetsLimited.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerGetsLimited=" << saTakerGetsLimited.getFullText();
// Got & Paid = Calculated by price and transfered without fees. // Got & Paid = Calculated by price and transfered without fees.
// Compute from got as when !bSell, we want got to be exact to finish off offer if possible. // Compute from got as when !bSell, we want got to be exact to finish off offer if possible.
@@ -1094,8 +1092,8 @@ bool STAmount::applyOffer(
: std::min(saOfferGetsAvailable, mulRound(saTakerGot, saOfferRate, saTakerFunds, true)); : std::min(saOfferGetsAvailable, mulRound(saTakerGot, saOfferRate, saTakerFunds, true));
saTakerPaid = std::min(saTakerPaid, saTakerPaysAvailable); // Due to rounding must clamp. saTakerPaid = std::min(saTakerPaid, saTakerPaysAvailable); // Due to rounding must clamp.
cLog(lsINFO) << "applyOffer: saTakerGot=" << saTakerGot.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerGot=" << saTakerGot.getFullText();
cLog(lsINFO) << "applyOffer: saTakerPaid=" << saTakerPaid.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerPaid=" << saTakerPaid.getFullText();
if (uTakerPaysRate == QUALITY_ONE) if (uTakerPaysRate == QUALITY_ONE)
{ {
@@ -1106,17 +1104,17 @@ bool STAmount::applyOffer(
// Compute fees in a rounding safe way. // Compute fees in a rounding safe way.
STAmount saTransferRate = STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9); STAmount saTransferRate = STAmount(CURRENCY_ONE, ACCOUNT_ONE, uTakerPaysRate, -9);
cLog(lsINFO) << "applyOffer: saTransferRate=" << saTransferRate.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTransferRate=" << saTransferRate.getFullText();
// TakerCost includes transfer fees. // TakerCost includes transfer fees.
STAmount saTakerCost = STAmount::mulRound(saTakerPaid, saTransferRate, true); STAmount saTakerCost = STAmount::mulRound(saTakerPaid, saTransferRate, true);
cLog(lsINFO) << "applyOffer: saTakerCost=" << saTakerCost.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerCost=" << saTakerCost.getFullText();
cLog(lsINFO) << "applyOffer: saTakerFunds=" << saTakerFunds.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerFunds=" << saTakerFunds.getFullText();
saTakerIssuerFee = saTakerCost > saTakerFunds saTakerIssuerFee = saTakerCost > saTakerFunds
? saTakerFunds-saTakerPaid // Not enough funds to cover fee, stiff issuer the rounding error. ? saTakerFunds-saTakerPaid // Not enough funds to cover fee, stiff issuer the rounding error.
: saTakerCost-saTakerPaid; : saTakerCost-saTakerPaid;
cLog(lsINFO) << "applyOffer: saTakerIssuerFee=" << saTakerIssuerFee.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerIssuerFee=" << saTakerIssuerFee.getFullText();
assert(!saTakerIssuerFee.isNegative()); assert(!saTakerIssuerFee.isNegative());
} }
@@ -1134,7 +1132,7 @@ bool STAmount::applyOffer(
: saOfferCost-saTakerGot; : saOfferCost-saTakerGot;
} }
cLog(lsINFO) << "applyOffer: saTakerGot=" << saTakerGot.getFullText(); WriteLog (lsINFO, STAmount) << "applyOffer: saTakerGot=" << saTakerGot.getFullText();
return saTakerGot >= saOfferPaysAvailable; // True, if consumed offer. return saTakerGot >= saOfferPaysAvailable; // True, if consumed offer.
} }
@@ -1436,7 +1434,7 @@ BOOST_AUTO_TEST_CASE( CustomCurrency_test )
BOOST_FAIL("STAmount multiply fail 4"); BOOST_FAIL("STAmount multiply fail 4");
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20") if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20")
{ {
cLog(lsFATAL) << "60/3 = " << WriteLog (lsFATAL, STAmount) << "60/3 = " <<
STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60),
STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText(); STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText();
BOOST_FAIL("STAmount divide fail"); BOOST_FAIL("STAmount divide fail");
@@ -1475,7 +1473,7 @@ static bool roundTest(int n, int d, int m)
if (res == cmp) if (res == cmp)
return true; return true;
cmp.throwComparable(res); cmp.throwComparable(res);
cLog(lsWARNING) << "(" << num.getText() << "/" << den.getText() << ") X " << mul.getText() << " = " WriteLog (lsWARNING, STAmount) << "(" << num.getText() << "/" << den.getText() << ") X " << mul.getText() << " = "
<< res.getText() << " not " << cmp.getText(); << res.getText() << " not " << cmp.getText();
BOOST_FAIL("Round fail"); BOOST_FAIL("Round fail");
return false; return false;
@@ -1492,7 +1490,7 @@ static void mulTest(int a, int b)
STAmount prod2(CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64>(a) * static_cast<uint64>(b)); STAmount prod2(CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64>(a) * static_cast<uint64>(b));
if (prod1 != prod2) if (prod1 != prod2)
{ {
cLog(lsWARNING) << "nn(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText() WriteLog (lsWARNING, STAmount) << "nn(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
<< " not " << prod2.getFullText(); << " not " << prod2.getFullText();
BOOST_WARN("Multiplication result is not exact"); BOOST_WARN("Multiplication result is not exact");
} }
@@ -1500,7 +1498,7 @@ static void mulTest(int a, int b)
prod1 = STAmount::multiply(aa, bb, CURRENCY_ONE, ACCOUNT_ONE); prod1 = STAmount::multiply(aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
if (prod1 != prod2) if (prod1 != prod2)
{ {
cLog(lsWARNING) << "n(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText() WriteLog (lsWARNING, STAmount) << "n(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
<< " not " << prod2.getFullText(); << " not " << prod2.getFullText();
BOOST_WARN("Multiplication result is not exact"); BOOST_WARN("Multiplication result is not exact");
} }
@@ -1518,7 +1516,7 @@ BOOST_AUTO_TEST_CASE( CurrencyMulDivTests )
b.setuint64(r); b.setuint64(r);
if (b.getuint64() != r) if (b.getuint64() != r)
{ {
cLog(lsFATAL) << r << " != " << b.getuint64() << " " << b.ToString(16); WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64() << " " << b.ToString(16);
BOOST_FAIL("setull64/getull64 failure"); BOOST_FAIL("setull64/getull64 failure");
} }
} }

View File

@@ -4,8 +4,6 @@
#include "SerializedTypes.h" #include "SerializedTypes.h"
#include "Log.h" #include "Log.h"
SETUP_LOG();
#if (ULONG_MAX > UINT_MAX) #if (ULONG_MAX > UINT_MAX)
#define BN_add_word64(bn, word) BN_add_word(bn, word) #define BN_add_word64(bn, word) BN_add_word(bn, word)
#define BN_sub_word64(bn, word) BN_sub_word(bn, word) #define BN_sub_word64(bn, word) BN_sub_word(bn, word)
@@ -15,11 +13,6 @@ SETUP_LOG();
#include "BigNum64.h" #include "BigNum64.h"
#endif #endif
static const uint64 tenTo14 = 100000000000000ull;
static const uint64 tenTo14m1 = tenTo14 - 1;
static const uint64 tenTo17 = tenTo14 * 1000;
static const uint64 tenTo17m1 = tenTo17 - 1;
// CAUTION: This is early code and is *NOT* ready for real use yet. // CAUTION: This is early code and is *NOT* ready for real use yet.
static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool roundUp) static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool roundUp)
@@ -27,7 +20,7 @@ static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool ro
if (!roundUp) // canonicalize already rounds down if (!roundUp) // canonicalize already rounds down
return; return;
cLog(lsTRACE) << "canonicalize< " << value << ":" << offset << (roundUp ? " up" : " down"); WriteLog (lsTRACE, STAmount) << "canonicalize< " << value << ":" << offset << (roundUp ? " up" : " down");
if (isNative) if (isNative)
{ {
if (offset < 0) if (offset < 0)
@@ -55,7 +48,7 @@ static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool ro
value /= 10; value /= 10;
++offset; ++offset;
} }
cLog(lsTRACE) << "canonicalize> " << value << ":" << offset << (roundUp ? " up" : " down"); WriteLog (lsTRACE, STAmount) << "canonicalize> " << value << ":" << offset << (roundUp ? " up" : " down");
} }
STAmount STAmount::addRound(const STAmount& v1, const STAmount& v2, bool roundUp) STAmount STAmount::addRound(const STAmount& v1, const STAmount& v2, bool roundUp)
@@ -307,37 +300,37 @@ BOOST_AUTO_TEST_CASE( amountRound_test )
STAmount oneThird1 = STAmount::divRound(one, three, CURRENCY_ONE, ACCOUNT_ONE, false); STAmount oneThird1 = STAmount::divRound(one, three, CURRENCY_ONE, ACCOUNT_ONE, false);
STAmount oneThird2 = STAmount::divide(one, three, CURRENCY_ONE, ACCOUNT_ONE); STAmount oneThird2 = STAmount::divide(one, three, CURRENCY_ONE, ACCOUNT_ONE);
STAmount oneThird3 = STAmount::divRound(one, three, CURRENCY_ONE, ACCOUNT_ONE, true); STAmount oneThird3 = STAmount::divRound(one, three, CURRENCY_ONE, ACCOUNT_ONE, true);
cLog(lsINFO) << oneThird1; WriteLog (lsINFO, STAmount) << oneThird1;
cLog(lsINFO) << oneThird2; WriteLog (lsINFO, STAmount) << oneThird2;
cLog(lsINFO) << oneThird3; WriteLog (lsINFO, STAmount) << oneThird3;
STAmount twoThird1 = STAmount::divRound(two, three, CURRENCY_ONE, ACCOUNT_ONE, false); STAmount twoThird1 = STAmount::divRound(two, three, CURRENCY_ONE, ACCOUNT_ONE, false);
STAmount twoThird2 = STAmount::divide(two, three, CURRENCY_ONE, ACCOUNT_ONE); STAmount twoThird2 = STAmount::divide(two, three, CURRENCY_ONE, ACCOUNT_ONE);
STAmount twoThird3 = STAmount::divRound(two, three, CURRENCY_ONE, ACCOUNT_ONE, true); STAmount twoThird3 = STAmount::divRound(two, three, CURRENCY_ONE, ACCOUNT_ONE, true);
cLog(lsINFO) << twoThird1; WriteLog (lsINFO, STAmount) << twoThird1;
cLog(lsINFO) << twoThird2; WriteLog (lsINFO, STAmount) << twoThird2;
cLog(lsINFO) << twoThird3; WriteLog (lsINFO, STAmount) << twoThird3;
STAmount oneA = STAmount::mulRound(oneThird1, three, CURRENCY_ONE, ACCOUNT_ONE, false); STAmount oneA = STAmount::mulRound(oneThird1, three, CURRENCY_ONE, ACCOUNT_ONE, false);
STAmount oneB = STAmount::multiply(oneThird2, three, CURRENCY_ONE, ACCOUNT_ONE); STAmount oneB = STAmount::multiply(oneThird2, three, CURRENCY_ONE, ACCOUNT_ONE);
STAmount oneC = STAmount::mulRound(oneThird3, three, CURRENCY_ONE, ACCOUNT_ONE, true); STAmount oneC = STAmount::mulRound(oneThird3, three, CURRENCY_ONE, ACCOUNT_ONE, true);
cLog(lsINFO) << oneA; WriteLog (lsINFO, STAmount) << oneA;
cLog(lsINFO) << oneB; WriteLog (lsINFO, STAmount) << oneB;
cLog(lsINFO) << oneC; WriteLog (lsINFO, STAmount) << oneC;
STAmount fourThirdsA = STAmount::addRound(twoThird2, twoThird2, false); STAmount fourThirdsA = STAmount::addRound(twoThird2, twoThird2, false);
STAmount fourThirdsB = twoThird2 + twoThird2; STAmount fourThirdsB = twoThird2 + twoThird2;
STAmount fourThirdsC = STAmount::addRound(twoThird2, twoThird2, true); STAmount fourThirdsC = STAmount::addRound(twoThird2, twoThird2, true);
cLog(lsINFO) << fourThirdsA; WriteLog (lsINFO, STAmount) << fourThirdsA;
cLog(lsINFO) << fourThirdsB; WriteLog (lsINFO, STAmount) << fourThirdsB;
cLog(lsINFO) << fourThirdsC; WriteLog (lsINFO, STAmount) << fourThirdsC;
STAmount dripTest1 = STAmount::mulRound(twoThird2, two, uint160(), uint160(), false); STAmount dripTest1 = STAmount::mulRound(twoThird2, two, uint160(), uint160(), false);
STAmount dripTest2 = STAmount::multiply(twoThird2, two, uint160(), uint160()); STAmount dripTest2 = STAmount::multiply(twoThird2, two, uint160(), uint160());
STAmount dripTest3 = STAmount::mulRound(twoThird2, two, uint160(), uint160(), true); STAmount dripTest3 = STAmount::mulRound(twoThird2, two, uint160(), uint160(), true);
cLog(lsINFO) << dripTest1; WriteLog (lsINFO, STAmount) << dripTest1;
cLog(lsINFO) << dripTest2; WriteLog (lsINFO, STAmount) << dripTest2;
cLog(lsINFO) << dripTest3; WriteLog (lsINFO, STAmount) << dripTest3;
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@@ -14,7 +14,6 @@
#include "Application.h" #include "Application.h"
#include "Log.h" #include "Log.h"
SETUP_LOG();
DECLARE_INSTANCE(HashedObject); DECLARE_INSTANCE(HashedObject);
HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) : HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) :
@@ -29,13 +28,13 @@ HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) :
mLevelDB = false; mLevelDB = false;
else else
{ {
cLog(lsFATAL) << "Incorrect database selection"; WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
assert(false); assert(false);
} }
#ifndef USE_LEVELDB #ifndef USE_LEVELDB
if (mLevelDB) if (mLevelDB)
{ {
cLog(lsFATAL) << "LevelDB has been selected but not compiled"; WriteLog (lsFATAL) << "LevelDB has been selected but not compiled";
assert(false); assert(false);
} }
#endif #endif
@@ -140,7 +139,7 @@ void HashedObjectStore::bulkWriteLevelDB(Job &)
leveldb::Status st = theApp->getHashNodeLDB()->Write(leveldb::WriteOptions(), &batch); leveldb::Status st = theApp->getHashNodeLDB()->Write(leveldb::WriteOptions(), &batch);
if (!st.ok()) if (!st.ok())
{ {
cLog(lsFATAL) << "Failed to store hash node"; WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
assert(false); assert(false);
} }
} }
@@ -174,7 +173,7 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB(const uint256& hash)
bufPtr + 9, sData.size() - 9, hash); bufPtr + 9, sData.size() - 9, hash);
mCache.canonicalize(hash, obj); mCache.canonicalize(hash, obj);
cLog(lsTRACE) << "HOS: " << hash << " fetch: in db"; WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
return obj; return obj;
} }
@@ -185,12 +184,12 @@ bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
{ // return: false = already in cache, true = added to cache { // return: false = already in cache, true = added to cache
if (!theApp->getHashNodeDB()) if (!theApp->getHashNodeDB())
{ {
cLog(lsTRACE) << "HOS: no db"; WriteLog (lsTRACE, HashedObject) << "HOS: no db";
return true; return true;
} }
if (mCache.touch(hash)) if (mCache.touch(hash))
{ {
cLog(lsTRACE) << "HOS: " << hash << " store: incache"; WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " store: incache";
return false; return false;
} }
assert(hash == Serializer::getSHA512Half(data)); assert(hash == Serializer::getSHA512Half(data));
@@ -198,7 +197,7 @@ bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
HashedObject::pointer object = boost::make_shared<HashedObject>(type, index, data, hash); HashedObject::pointer object = boost::make_shared<HashedObject>(type, index, data, hash);
if (!mCache.canonicalize(hash, object)) if (!mCache.canonicalize(hash, object))
{ {
// cLog(lsTRACE) << "Queuing write for " << hash; // WriteLog (lsTRACE, HashedObject) << "Queuing write for " << hash;
boost::mutex::scoped_lock sl(mWriteMutex); boost::mutex::scoped_lock sl(mWriteMutex);
mWriteSet.push_back(object); mWriteSet.push_back(object);
if (!mWritePending) if (!mWritePending)
@@ -209,7 +208,7 @@ bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
} }
} }
// else // else
// cLog(lsTRACE) << "HOS: already had " << hash; // WriteLog (lsTRACE, HashedObject) << "HOS: already had " << hash;
mNegativeCache.del(hash); mNegativeCache.del(hash);
return true; return true;
} }
@@ -234,7 +233,7 @@ void HashedObjectStore::bulkWriteSQLite(Job&)
return; return;
} }
} }
// cLog(lsTRACE) << "HOS: writing " << set.size(); // WriteLog (lsTRACE, HashedObject) << "HOS: writing " << set.size();
#ifndef NO_SQLITE3_PREPARE #ifndef NO_SQLITE3_PREPARE
@@ -269,7 +268,7 @@ void HashedObjectStore::bulkWriteSQLite(Job&)
int ret = pSt.step(); int ret = pSt.step();
if (!pSt.isDone(ret)) if (!pSt.isDone(ret))
{ {
cLog(lsFATAL) << "Error saving hashed object " << ret; WriteLog (lsFATAL, HashedObject) << "Error saving hashed object " << ret;
assert(false); assert(false);
} }
pSt.reset(); pSt.reset();
@@ -343,7 +342,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
{ {
pSt.reset(); pSt.reset();
mNegativeCache.add(hash); mNegativeCache.add(hash);
cLog(lsTRACE) << "HOS: " << hash <<" fetch: not in db"; WriteLog (lsTRACE, HashedObject) << "HOS: " << hash <<" fetch: not in db";
return obj; return obj;
} }
@@ -394,7 +393,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
case 'N': htype = hotTRANSACTION_NODE; break; case 'N': htype = hotTRANSACTION_NODE; break;
default: default:
assert(false); assert(false);
cLog(lsERROR) << "Invalid hashed object"; WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
mNegativeCache.add(hash); mNegativeCache.add(hash);
return obj; return obj;
} }
@@ -402,7 +401,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
obj = boost::make_shared<HashedObject>(htype, index, data, hash); obj = boost::make_shared<HashedObject>(htype, index, data, hash);
mCache.canonicalize(hash, obj); mCache.canonicalize(hash, obj);
cLog(lsTRACE) << "HOS: " << hash << " fetch: in db"; WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
return obj; return obj;
} }
@@ -410,7 +409,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
int HashedObjectStore::import(const std::string& file) int HashedObjectStore::import(const std::string& file)
{ {
cLog(lsWARNING) << "Hashed object import from \"" << file << "\"."; WriteLog (lsWARNING, HashedObject) << "Hashed object import from \"" << file << "\".";
UPTR_T<Database> importDB(new SqliteDatabase(file.c_str())); UPTR_T<Database> importDB(new SqliteDatabase(file.c_str()));
importDB->connect(); importDB->connect();
@@ -427,7 +426,7 @@ int HashedObjectStore::import(const std::string& file)
hash.SetHexExact(hashStr); hash.SetHexExact(hashStr);
if (hash.isZero()) if (hash.isZero())
{ {
cLog(lsWARNING) << "zero hash found in import table"; WriteLog (lsWARNING, HashedObject) << "zero hash found in import table";
} }
else else
{ {
@@ -453,7 +452,7 @@ int HashedObjectStore::import(const std::string& file)
case 'N': htype = hotTRANSACTION_NODE; break; case 'N': htype = hotTRANSACTION_NODE; break;
default: default:
assert(false); assert(false);
cLog(lsERROR) << "Invalid hashed object"; WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
} }
*(bufPtr + 8) = static_cast<unsigned char>(htype); *(bufPtr + 8) = static_cast<unsigned char>(htype);
@@ -462,18 +461,18 @@ int HashedObjectStore::import(const std::string& file)
leveldb::Slice(reinterpret_cast<const char *>(bufPtr), rawData.size())); leveldb::Slice(reinterpret_cast<const char *>(bufPtr), rawData.size()));
if (!st.ok()) if (!st.ok())
{ {
cLog(lsFATAL) << "Failed to store hash node"; WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
assert(false); assert(false);
} }
++count; ++count;
} }
if ((count % 10000) == 0) if ((count % 10000) == 0)
{ {
cLog(lsINFO) << "Import in progress: " << count; WriteLog (lsINFO, HashedObject) << "Import in progress: " << count;
} }
} }
cLog(lsWARNING) << "Imported " << count << " nodes"; WriteLog (lsWARNING, HashedObject) << "Imported " << count << " nodes";
return count; return count;
} }

View File

@@ -8,7 +8,10 @@
#define SECTION_DEFAULT_NAME "" #define SECTION_DEFAULT_NAME ""
SETUP_LOG(); // for logging
struct ParseSectionLog
{
};
section ParseSection(const std::string& strInput, const bool bTrim) section ParseSection(const std::string& strInput, const bool bTrim)
{ {
@@ -118,7 +121,7 @@ bool sectionSingleB(section& secSource, const std::string& strSection, std::stri
} }
else if (pmtEntries) else if (pmtEntries)
{ {
cLog(lsWARNING) << boost::str(boost::format("Section [%s]: requires 1 line not %d lines.") WriteLog (lsWARNING, ParseSectionLog) << boost::str(boost::format("Section [%s]: requires 1 line not %d lines.")
% strSection % strSection
% pmtEntries->size()); % pmtEntries->size());
} }

View File

@@ -12,8 +12,6 @@
#include "Serializer.h" #include "Serializer.h"
#include "Log.h" #include "Log.h"
SETUP_LOG();
bool powResultInfo(POWResult powCode, std::string& strToken, std::string& strHuman) bool powResultInfo(POWResult powCode, std::string& strToken, std::string& strHuman)
{ {
@@ -66,7 +64,7 @@ bool ProofOfWork::isValid() const
{ {
if ((mIterations <= sMaxIterations) && (mTarget >= sMinTarget)) if ((mIterations <= sMaxIterations) && (mTarget >= sMinTarget))
return true; return true;
cLog(lsWARNING) << "Invalid PoW: " << mIterations << ", " << mTarget; WriteLog (lsWARNING, ProofOfWork) << "Invalid PoW: " << mIterations << ", " << mTarget;
return false; return false;
} }
@@ -74,10 +72,10 @@ uint64 ProofOfWork::getDifficulty(const uint256& target, int iterations)
{ // calculate the approximate number of hashes required to solve this proof of work { // calculate the approximate number of hashes required to solve this proof of work
if ((iterations > sMaxIterations) || (target < sMinTarget)) if ((iterations > sMaxIterations) || (target < sMinTarget))
{ {
cLog(lsINFO) << "Iterations:" << iterations; WriteLog (lsINFO, ProofOfWork) << "Iterations:" << iterations;
cLog(lsINFO) << "MaxIterat: " << sMaxIterations; WriteLog (lsINFO, ProofOfWork) << "MaxIterat: " << sMaxIterations;
cLog(lsINFO) << "Target: " << target; WriteLog (lsINFO, ProofOfWork) << "Target: " << target;
cLog(lsINFO) << "MinTarget: " << sMinTarget; WriteLog (lsINFO, ProofOfWork) << "MinTarget: " << sMinTarget;
throw std::runtime_error("invalid proof of work target/iteration"); throw std::runtime_error("invalid proof of work target/iteration");
} }
@@ -195,14 +193,14 @@ POWResult ProofOfWorkGenerator::checkProof(const std::string& token, const uint2
boost::split(fields, token, boost::algorithm::is_any_of("-")); boost::split(fields, token, boost::algorithm::is_any_of("-"));
if (fields.size() != 5) if (fields.size() != 5)
{ {
cLog(lsDEBUG) << "PoW " << token << " is corrupt"; WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " is corrupt";
return powCORRUPT; return powCORRUPT;
} }
std::string v = mSecret.GetHex() + fields[0] + "-" + fields[1] + "-" + fields[2] + "-" + fields[3]; std::string v = mSecret.GetHex() + fields[0] + "-" + fields[1] + "-" + fields[2] + "-" + fields[3];
if (fields[4] != Serializer::getSHA512Half(v).GetHex()) if (fields[4] != Serializer::getSHA512Half(v).GetHex())
{ {
cLog(lsDEBUG) << "PoW " << token << " has a bad token"; WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has a bad token";
return powCORRUPT; return powCORRUPT;
} }
@@ -219,13 +217,13 @@ POWResult ProofOfWorkGenerator::checkProof(const std::string& token, const uint2
boost::mutex::scoped_lock sl(mLock); boost::mutex::scoped_lock sl(mLock);
if ((t * 4) > (now + mValidTime)) if ((t * 4) > (now + mValidTime))
{ {
cLog(lsDEBUG) << "PoW " << token << " has expired"; WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has expired";
return powEXPIRED; return powEXPIRED;
} }
if (((iterations != mIterations) || (target != mTarget)) && getPowEntry(target, iterations) < (mPowEntry - 2)) if (((iterations != mIterations) || (target != mTarget)) && getPowEntry(target, iterations) < (mPowEntry - 2))
{ // difficulty has increased more than two times since PoW requested { // difficulty has increased more than two times since PoW requested
cLog(lsINFO) << "Difficulty has increased since PoW requested"; WriteLog (lsINFO, ProofOfWork) << "Difficulty has increased since PoW requested";
return powTOOEASY; return powTOOEASY;
} }
} }
@@ -233,7 +231,7 @@ POWResult ProofOfWorkGenerator::checkProof(const std::string& token, const uint2
ProofOfWork pow(token, iterations, challenge, target); ProofOfWork pow(token, iterations, challenge, target);
if (!pow.checkSolution(solution)) if (!pow.checkSolution(solution))
{ {
cLog(lsDEBUG) << "PoW " << token << " has a bad nonce"; WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has a bad nonce";
return powBADNONCE; return powBADNONCE;
} }
@@ -241,7 +239,7 @@ POWResult ProofOfWorkGenerator::checkProof(const std::string& token, const uint2
boost::mutex::scoped_lock sl(mLock); boost::mutex::scoped_lock sl(mLock);
if (!mSolvedChallenges.insert(powMap_vt(now, challenge)).second) if (!mSolvedChallenges.insert(powMap_vt(now, challenge)).second)
{ {
cLog(lsDEBUG) << "PoW " << token << " has been reused"; WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has been reused";
return powREUSED; return powREUSED;
} }
} }
@@ -370,14 +368,14 @@ BOOST_AUTO_TEST_CASE( ProofOfWork_test )
{ {
ProofOfWorkGenerator gen; ProofOfWorkGenerator gen;
ProofOfWork pow = gen.getProof(); ProofOfWork pow = gen.getProof();
cLog(lsINFO) << "Estimated difficulty: " << pow.getDifficulty(); WriteLog (lsINFO, ProofOfWork) << "Estimated difficulty: " << pow.getDifficulty();
uint256 solution = pow.solve(16777216); uint256 solution = pow.solve(16777216);
if (solution.isZero()) if (solution.isZero())
BOOST_FAIL("Unable to solve proof of work"); BOOST_FAIL("Unable to solve proof of work");
if (!pow.checkSolution(solution)) if (!pow.checkSolution(solution))
BOOST_FAIL("Solution did not check"); BOOST_FAIL("Solution did not check");
cLog(lsDEBUG) << "A bad nonce error is expected"; WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
POWResult r = gen.checkProof(pow.getToken(), uint256()); POWResult r = gen.checkProof(pow.getToken(), uint256());
if (r != powBADNONCE) if (r != powBADNONCE)
{ {
@@ -386,7 +384,7 @@ BOOST_AUTO_TEST_CASE( ProofOfWork_test )
} }
if (gen.checkProof(pow.getToken(), solution) != powOK) if (gen.checkProof(pow.getToken(), solution) != powOK)
BOOST_FAIL("Solution did not check with issuer"); BOOST_FAIL("Solution did not check with issuer");
cLog(lsDEBUG) << "A reused nonce error is expected"; WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
if (gen.checkProof(pow.getToken(), solution) != powREUSED) if (gen.checkProof(pow.getToken(), solution) != powREUSED)
BOOST_FAIL("Reuse solution not detected"); BOOST_FAIL("Reuse solution not detected");
@@ -395,16 +393,16 @@ BOOST_AUTO_TEST_CASE( ProofOfWork_test )
{ {
gen.setDifficulty(i); gen.setDifficulty(i);
ProofOfWork pow = gen.getProof(); ProofOfWork pow = gen.getProof();
cLog(lsINFO) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty(); WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty();
uint256 solution = pow.solve(131072); uint256 solution = pow.solve(131072);
if (solution.isZero()) if (solution.isZero())
cLog(lsINFO) << "Giving up"; WriteLog (lsINFO, ProofOfWork) << "Giving up";
else else
{ {
cLog(lsINFO) << "Solution found"; WriteLog (lsINFO, ProofOfWork) << "Solution found";
if (gen.checkProof(pow.getToken(), solution) != powOK) if (gen.checkProof(pow.getToken(), solution) != powOK)
{ {
cLog(lsFATAL) << "Solution fails"; WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
} }
} }
} }

View File

@@ -6,8 +6,6 @@
#include "Log.h" #include "Log.h"
SETUP_LOG();
inline uint32 min(uint32 x, uint32 y) { return (x < y) ? x : y; } inline uint32 min(uint32 x, uint32 y) { return (x < y) ? x : y; }
inline uint32 max(uint32 x, uint32 y) { return (x > y) ? x : y; } inline uint32 max(uint32 x, uint32 y) { return (x > y) ? x : y; }
@@ -54,7 +52,7 @@ uint32 RangeSet::getPrev(uint32 v) const
uint32 RangeSet::prevMissing(uint32 v) const uint32 RangeSet::prevMissing(uint32 v) const
{ // largest number not in the set that is less than the given number { // largest number not in the set that is less than the given number
cLog(lsTRACE) << "prevMissing(" << v << ") " << toString(); WriteLog (lsTRACE, RangeSet) << "prevMissing(" << v << ") " << toString();
for (const_reverse_iterator it = rbegin(); it != rend(); ++it) for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
{ {
if ((upper(it) + 1) < v) if ((upper(it) + 1) < v)
@@ -111,7 +109,7 @@ BOOST_AUTO_TEST_SUITE(RangeSet_suite)
BOOST_AUTO_TEST_CASE(RangeSet_test) BOOST_AUTO_TEST_CASE(RangeSet_test)
{ {
cLog(lsTRACE) << "RangeSet test begins"; WriteLog (lsTRACE, RangeSet) << "RangeSet test begins";
RangeSet r1, r2; RangeSet r1, r2;
@@ -127,7 +125,7 @@ BOOST_AUTO_TEST_CASE(RangeSet_test)
// TODO: Traverse functions must be tested // TODO: Traverse functions must be tested
cLog(lsTRACE) << "RangeSet test complete"; WriteLog (lsTRACE, RangeSet) << "RangeSet test complete";
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@@ -19,8 +19,6 @@
#define STATE_MAP_BUCKETS 1024 #define STATE_MAP_BUCKETS 1024
#endif #endif
SETUP_LOG();
DECLARE_INSTANCE(SHAMap); DECLARE_INSTANCE(SHAMap);
DECLARE_INSTANCE(SHAMapItem); DECLARE_INSTANCE(SHAMapItem);
DECLARE_INSTANCE(SHAMapTreeNode); DECLARE_INSTANCE(SHAMapTreeNode);
@@ -140,12 +138,12 @@ void SHAMap::dirtyUp(std::stack<SHAMapTreeNode::pointer>& stack, const uint256&
if (!node->setChildHash(branch, prevHash)) if (!node->setChildHash(branch, prevHash))
{ {
cLog(lsFATAL) << "dirtyUp terminates early"; WriteLog (lsFATAL, SHAMap) << "dirtyUp terminates early";
assert(false); assert(false);
return; return;
} }
#ifdef ST_DEBUG #ifdef ST_DEBUG
cLog(lsTRACE) << "dirtyUp sets branch " << branch << " to " << prevHash; WriteLog (lsTRACE, SHAMap) << "dirtyUp sets branch " << branch << " to " << prevHash;
#endif #endif
prevHash = node->getNodeHash(); prevHash = node->getNodeHash();
assert(prevHash.isNonZero()); assert(prevHash.isNonZero());
@@ -213,10 +211,10 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& id, const uint256& has
#ifdef DEBUG #ifdef DEBUG
if (node->getNodeHash() != hash) if (node->getNodeHash() != hash)
{ {
cLog(lsFATAL) << "Attempt to get node, hash not in tree"; WriteLog (lsFATAL, SHAMap) << "Attempt to get node, hash not in tree";
cLog(lsFATAL) << "ID: " << id; WriteLog (lsFATAL, SHAMap) << "ID: " << id;
cLog(lsFATAL) << "TgtHash " << hash; WriteLog (lsFATAL, SHAMap) << "TgtHash " << hash;
cLog(lsFATAL) << "NodHash " << node->getNodeHash(); WriteLog (lsFATAL, SHAMap) << "NodHash " << node->getNodeHash();
throw std::runtime_error("invalid node"); throw std::runtime_error("invalid node");
} }
#endif #endif
@@ -351,7 +349,7 @@ SHAMapItem::pointer SHAMap::onlyBelow(SHAMapTreeNode* node)
if (!nextNode) if (!nextNode)
{ {
cLog(lsFATAL) << *node; WriteLog (lsFATAL, SHAMap) << *node;
assert(false); assert(false);
return SHAMapItem::pointer(); return SHAMapItem::pointer();
} }
@@ -620,8 +618,8 @@ bool SHAMap::addGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMeta)
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(branch), item, type, mSeq); boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(branch), item, type, mSeq);
if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second) if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second)
{ {
cLog(lsFATAL) << "Node: " << *node; WriteLog (lsFATAL, SHAMap) << "Node: " << *node;
cLog(lsFATAL) << "NewNode: " << *newNode; WriteLog (lsFATAL, SHAMap) << "NewNode: " << *newNode;
dump(); dump();
assert(false); assert(false);
throw std::runtime_error("invalid inner node"); throw std::runtime_error("invalid inner node");
@@ -701,7 +699,7 @@ bool SHAMap::updateGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMe
if (!node->setItem(item, !isTransaction ? SHAMapTreeNode::tnACCOUNT_STATE : if (!node->setItem(item, !isTransaction ? SHAMapTreeNode::tnACCOUNT_STATE :
(hasMeta ? SHAMapTreeNode::tnTRANSACTION_MD : SHAMapTreeNode::tnTRANSACTION_NM))) (hasMeta ? SHAMapTreeNode::tnTRANSACTION_MD : SHAMapTreeNode::tnTRANSACTION_NM)))
{ {
cLog(lsWARNING) << "SHAMap setItem, no change"; WriteLog (lsWARNING, SHAMap) << "SHAMap setItem, no change";
return true; return true;
} }
@@ -711,7 +709,7 @@ bool SHAMap::updateGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMe
void SHAMapItem::dump() void SHAMapItem::dump()
{ {
cLog(lsINFO) << "SHAMapItem(" << mTag << ") " << mData.size() << "bytes"; WriteLog (lsINFO, SHAMap) << "SHAMapItem(" << mTag << ") " << mData.size() << "bytes";
} }
SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const uint256& hash) SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const uint256& hash)
@@ -722,7 +720,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
HashedObject::pointer obj(theApp->getHashedObjectStore().retrieve(hash)); HashedObject::pointer obj(theApp->getHashedObjectStore().retrieve(hash));
if (!obj) if (!obj)
{ {
// cLog(lsTRACE) << "fetchNodeExternal: missing " << hash; // WriteLog (lsTRACE, SHAMap) << "fetchNodeExternal: missing " << hash;
if (mLedgerSeq != 0) if (mLedgerSeq != 0)
{ {
theApp->getOPs().missingNodeInLedger(mLedgerSeq); theApp->getOPs().missingNodeInLedger(mLedgerSeq);
@@ -737,13 +735,13 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
boost::make_shared<SHAMapTreeNode>(id, obj->getData(), mSeq, snfPREFIX, hash, true); boost::make_shared<SHAMapTreeNode>(id, obj->getData(), mSeq, snfPREFIX, hash, true);
if (id != *ret) if (id != *ret)
{ {
cLog(lsFATAL) << "id:" << id << ", got:" << *ret; WriteLog (lsFATAL, SHAMap) << "id:" << id << ", got:" << *ret;
assert(false); assert(false);
return SHAMapTreeNode::pointer(); return SHAMapTreeNode::pointer();
} }
if (ret->getNodeHash() != hash) if (ret->getNodeHash() != hash)
{ {
cLog(lsFATAL) << "Hashes don't match"; WriteLog (lsFATAL, SHAMap) << "Hashes don't match";
assert(false); assert(false);
return SHAMapTreeNode::pointer(); return SHAMapTreeNode::pointer();
} }
@@ -756,7 +754,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
} }
catch (...) catch (...)
{ {
cLog(lsWARNING) << "fetchNodeExternal gets an invalid node: " << hash; WriteLog (lsWARNING, SHAMap) << "fetchNodeExternal gets an invalid node: " << hash;
throw SHAMapMissingNode(mType, id, hash); throw SHAMapMissingNode(mType, id, hash);
} }
} }
@@ -765,14 +763,14 @@ void SHAMap::fetchRoot(const uint256& hash, SHAMapSyncFilter* filter)
{ {
if (hash == root->getNodeHash()) if (hash == root->getNodeHash())
return; return;
if (sLog(lsTRACE)) if (ShouldLog (lsTRACE, SHAMap))
{ {
if (mType == smtTRANSACTION) if (mType == smtTRANSACTION)
cLog(lsTRACE) << "Fetch root TXN node " << hash; WriteLog (lsTRACE, SHAMap) << "Fetch root TXN node " << hash;
else if (mType == smtSTATE) else if (mType == smtSTATE)
cLog(lsTRACE) << "Fetch root STATE node " << hash; WriteLog (lsTRACE, SHAMap) << "Fetch root STATE node " << hash;
else else
cLog(lsTRACE) << "Fetch root SHAMap node " << hash; WriteLog (lsTRACE, SHAMap) << "Fetch root SHAMap node " << hash;
} }
try try
{ {
@@ -812,9 +810,9 @@ int SHAMap::flushDirty(SHADirtyMap& map, int maxNodes, HashedObjectType t, uint3
#ifdef DEBUG #ifdef DEBUG
if (s.getSHA512Half() != it->second->getNodeHash()) if (s.getSHA512Half() != it->second->getNodeHash())
{ {
cLog(lsFATAL) << *(it->second); WriteLog (lsFATAL, SHAMap) << *(it->second);
cLog(lsFATAL) << lexical_cast_i(s.getDataLength()); WriteLog (lsFATAL, SHAMap) << lexical_cast_i(s.getDataLength());
cLog(lsFATAL) << s.getSHA512Half() << " != " << it->second->getNodeHash(); WriteLog (lsFATAL, SHAMap) << s.getSHA512Half() << " != " << it->second->getNodeHash();
assert(false); assert(false);
} }
#endif #endif
@@ -908,13 +906,13 @@ void SHAMap::dropBelow(SHAMapTreeNode* d)
void SHAMap::dump(bool hash) void SHAMap::dump(bool hash)
{ {
cLog(lsINFO) << " MAP Contains"; WriteLog (lsINFO, SHAMap) << " MAP Contains";
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
for(boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer>::iterator it = mTNByID.begin(); for(boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer>::iterator it = mTNByID.begin();
it != mTNByID.end(); ++it) it != mTNByID.end(); ++it)
{ {
cLog(lsINFO) << it->second->getString(); WriteLog (lsINFO, SHAMap) << it->second->getString();
tLog(hash, lsINFO) << it->second->getNodeHash(); CondLog (hash, lsINFO, SHAMap) << it->second->getNodeHash();
} }
} }
@@ -931,7 +929,7 @@ BOOST_AUTO_TEST_SUITE(SHAMap_suite)
BOOST_AUTO_TEST_CASE( SHAMap_test ) BOOST_AUTO_TEST_CASE( SHAMap_test )
{ // h3 and h4 differ only in the leaf, same terminal node (level 19) { // h3 and h4 differ only in the leaf, same terminal node (level 19)
cLog(lsTRACE) << "SHAMap test"; WriteLog (lsTRACE, SHAMap) << "SHAMap test";
uint256 h1, h2, h3, h4, h5; uint256 h1, h2, h3, h4, h5;
h1.SetHex("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7"); h1.SetHex("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
h2.SetHex("436ccbac3347baa1f1e53baeef1f43334da88f1f6d70d963b833afd6dfa289fe"); h2.SetHex("436ccbac3347baa1f1e53baeef1f43334da88f1f6d70d963b833afd6dfa289fe");
@@ -967,7 +965,7 @@ BOOST_AUTO_TEST_CASE( SHAMap_test )
i = sMap.peekNextItem(i->getTag()); i = sMap.peekNextItem(i->getTag());
if (i) BOOST_FAIL("bad traverse"); if (i) BOOST_FAIL("bad traverse");
cLog(lsTRACE) << "SHAMap snap test"; WriteLog (lsTRACE, SHAMap) << "SHAMap snap test";
uint256 mapHash = sMap.getHash(); uint256 mapHash = sMap.getHash();
SHAMap::pointer map2 = sMap.snapShot(false); SHAMap::pointer map2 = sMap.snapShot(false);
if (sMap.getHash() != mapHash) BOOST_FAIL("bad snapshot"); if (sMap.getHash() != mapHash) BOOST_FAIL("bad snapshot");

View File

@@ -16,8 +16,6 @@
#include "Log.h" #include "Log.h"
#include "HashPrefixes.h" #include "HashPrefixes.h"
SETUP_LOG();
std::string SHAMapNode::getString() const std::string SHAMapNode::getString() const
{ {
static boost::format NodeID("NodeID(%s,%s)"); static boost::format NodeID("NodeID(%s,%s)");
@@ -152,7 +150,7 @@ int SHAMapNode::selectBranch(const uint256& hash) const
void SHAMapNode::dump() const void SHAMapNode::dump() const
{ {
cLog(lsDEBUG) << getString(); WriteLog (lsDEBUG, SHAMapNode) << getString();
} }
SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0), SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0),
@@ -254,7 +252,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
{ {
if (rawNode.size() < 4) if (rawNode.size() < 4)
{ {
cLog(lsINFO) << "size < 4"; WriteLog (lsINFO, SHAMapNode) << "size < 4";
throw std::runtime_error("invalid P node"); throw std::runtime_error("invalid P node");
} }
@@ -276,7 +274,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
s.chop(32); s.chop(32);
if (u.isZero()) if (u.isZero())
{ {
cLog(lsINFO) << "invalid PLN node"; WriteLog (lsINFO, SHAMapNode) << "invalid PLN node";
throw std::runtime_error("invalid PLN node"); throw std::runtime_error("invalid PLN node");
} }
mItem = boost::make_shared<SHAMapItem>(u, s.peekData()); mItem = boost::make_shared<SHAMapItem>(u, s.peekData());
@@ -306,7 +304,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
} }
else else
{ {
cLog(lsINFO) << "Unknown node prefix " << std::hex << prefix << std::dec; WriteLog (lsINFO, SHAMapNode) << "Unknown node prefix " << std::hex << prefix << std::dec;
throw std::runtime_error("invalid node prefix"); throw std::runtime_error("invalid node prefix");
} }
} }
@@ -504,7 +502,7 @@ void SHAMapTreeNode::makeInner()
void SHAMapTreeNode::dump() void SHAMapTreeNode::dump()
{ {
cLog(lsDEBUG) << "SHAMapTreeNode(" << getNodeID() << ")"; WriteLog (lsDEBUG, SHAMapNode) << "SHAMapTreeNode(" << getNodeID() << ")";
} }
std::string SHAMapTreeNode::getString() const std::string SHAMapTreeNode::getString() const

View File

@@ -11,8 +11,6 @@
#include "Log.h" #include "Log.h"
SETUP_LOG();
static const uint256 uZero; static const uint256 uZero;
KeyCache<uint256> SHAMap::fullBelowCache("fullBelowCache", 65536, 240); KeyCache<uint256> SHAMap::fullBelowCache("fullBelowCache", 65536, 240);
@@ -32,7 +30,7 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
if (!root->isInner()) if (!root->isInner())
{ {
cLog(lsWARNING) << "synching empty tree"; WriteLog (lsWARNING, SHAMap) << "synching empty tree";
return; return;
} }
@@ -165,13 +163,13 @@ bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector<SHAMapNode>& nodeI
SHAMapTreeNode::pointer node = getNode(wanted); SHAMapTreeNode::pointer node = getNode(wanted);
if (!node) if (!node)
{ {
cLog(lsWARNING) << "peer requested node that is not in the map: " << wanted; WriteLog (lsWARNING, SHAMap) << "peer requested node that is not in the map: " << wanted;
throw std::runtime_error("Peer requested node not in map"); throw std::runtime_error("Peer requested node not in map");
} }
if (node->isInner() && node->isEmpty()) if (node->isInner() && node->isEmpty())
{ {
cLog(lsWARNING) << "peer requests empty node"; WriteLog (lsWARNING, SHAMap) << "peer requests empty node";
return false; return false;
} }
@@ -215,7 +213,7 @@ SMAddNode SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANod
// we already have a root node // we already have a root node
if (root->getNodeHash().isNonZero()) if (root->getNodeHash().isNonZero())
{ {
cLog(lsTRACE) << "got root node, already have one"; WriteLog (lsTRACE, SHAMap) << "got root node, already have one";
return SMAddNode::okay(); return SMAddNode::okay();
} }
@@ -254,7 +252,7 @@ SMAddNode SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned ch
// we already have a root node // we already have a root node
if (root->getNodeHash().isNonZero()) if (root->getNodeHash().isNonZero())
{ {
cLog(lsTRACE) << "got root node, already have one"; WriteLog (lsTRACE, SHAMap) << "got root node, already have one";
assert(root->getNodeHash() == hash); assert(root->getNodeHash() == hash);
return SMAddNode::okay(); return SMAddNode::okay();
} }
@@ -288,7 +286,7 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
assert(!node.isRoot()); assert(!node.isRoot());
if (!isSynching()) if (!isSynching())
{ {
cLog(lsTRACE) << "AddKnownNode while not synching"; WriteLog (lsTRACE, SHAMap) << "AddKnownNode while not synching";
return SMAddNode::okay(); return SMAddNode::okay();
} }
@@ -305,7 +303,7 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
if (iNode->isEmptyBranch(branch)) if (iNode->isEmptyBranch(branch))
{ {
cLog(lsWARNING) << "Add known node for empty branch" << node; WriteLog (lsWARNING, SHAMap) << "Add known node for empty branch" << node;
return SMAddNode::invalid(); return SMAddNode::invalid();
} }
if (fullBelowCache.isPresent(iNode->getChildHash(branch))) if (fullBelowCache.isPresent(iNode->getChildHash(branch)))
@@ -319,9 +317,9 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
{ {
if (iNode->getDepth() != (node.getDepth() - 1)) if (iNode->getDepth() != (node.getDepth() - 1))
{ // Either this node is broken or we didn't request it (yet) { // Either this node is broken or we didn't request it (yet)
cLog(lsWARNING) << "unable to hook node " << node; WriteLog (lsWARNING, SHAMap) << "unable to hook node " << node;
cLog(lsINFO) << " stuck at " << *iNode; WriteLog (lsINFO, SHAMap) << " stuck at " << *iNode;
cLog(lsINFO) << "got depth=" << node.getDepth() << ", walked to= " << iNode->getDepth(); WriteLog (lsINFO, SHAMap) << "got depth=" << node.getDepth() << ", walked to= " << iNode->getDepth();
return SMAddNode::invalid(); return SMAddNode::invalid();
} }
@@ -329,7 +327,7 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
boost::make_shared<SHAMapTreeNode>(node, rawNode, mSeq - 1, snfWIRE, uZero, false); boost::make_shared<SHAMapTreeNode>(node, rawNode, mSeq - 1, snfWIRE, uZero, false);
if (iNode->getChildHash(branch) != newNode->getNodeHash()) if (iNode->getChildHash(branch) != newNode->getNodeHash())
{ {
cLog(lsWARNING) << "Corrupt node recevied"; WriteLog (lsWARNING, SHAMap) << "Corrupt node recevied";
return SMAddNode::invalid(); return SMAddNode::invalid();
} }
@@ -344,7 +342,7 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
} }
} }
cLog(lsTRACE) << "got node, already had it (late)"; WriteLog (lsTRACE, SHAMap) << "got node, already had it (late)";
return SMAddNode::okay(); return SMAddNode::okay();
} }
@@ -365,16 +363,16 @@ bool SHAMap::deepCompare(SHAMap& other)
if (!otherNode) if (!otherNode)
{ {
cLog(lsINFO) << "unable to fetch node"; WriteLog (lsINFO, SHAMap) << "unable to fetch node";
return false; return false;
} }
else if (otherNode->getNodeHash() != node->getNodeHash()) else if (otherNode->getNodeHash() != node->getNodeHash())
{ {
cLog(lsWARNING) << "node hash mismatch"; WriteLog (lsWARNING, SHAMap) << "node hash mismatch";
return false; return false;
} }
// cLog(lsTRACE) << "Comparing inner nodes " << *node; // WriteLog (lsTRACE) << "Comparing inner nodes " << *node;
if (node->getNodeHash() != otherNode->getNodeHash()) if (node->getNodeHash() != otherNode->getNodeHash())
return false; return false;
@@ -399,7 +397,7 @@ bool SHAMap::deepCompare(SHAMap& other)
SHAMapTreeNode::pointer next = getNode(node->getChildNodeID(i), node->getChildHash(i), false); SHAMapTreeNode::pointer next = getNode(node->getChildNodeID(i), node->getChildHash(i), false);
if (!next) if (!next)
{ {
cLog(lsWARNING) << "unable to fetch inner node"; WriteLog (lsWARNING, SHAMap) << "unable to fetch inner node";
return false; return false;
} }
stack.push(next); stack.push(next);
@@ -450,7 +448,7 @@ std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool incl
(boost::ref(have->mLock), boost::try_to_lock); (boost::ref(have->mLock), boost::try_to_lock);
if (!(*ul2)) if (!(*ul2))
{ {
cLog(lsINFO) << "Unable to create pack due to lock"; WriteLog (lsINFO, SHAMap) << "Unable to create pack due to lock";
return ret; return ret;
} }
} }
@@ -543,7 +541,7 @@ static bool confuseMap(SHAMap &map, int count)
items.push_back(item->getTag()); items.push_back(item->getTag());
if (!map.addItem(*item, false, false)) if (!map.addItem(*item, false, false))
{ {
cLog(lsFATAL) << "Unable to add item to map"; WriteLog (lsFATAL, SHAMap) << "Unable to add item to map";
return false; return false;
} }
} }
@@ -552,14 +550,14 @@ static bool confuseMap(SHAMap &map, int count)
{ {
if (!map.delItem(*it)) if (!map.delItem(*it))
{ {
cLog(lsFATAL) << "Unable to remove item from map"; WriteLog (lsFATAL, SHAMap) << "Unable to remove item from map";
return false; return false;
} }
} }
if (beforeHash != map.getHash()) if (beforeHash != map.getHash())
{ {
cLog(lsFATAL) << "Hashes do not match"; WriteLog (lsFATAL, SHAMap) << "Hashes do not match";
return false; return false;
} }
@@ -590,26 +588,26 @@ BOOST_AUTO_TEST_SUITE( SHAMapSync )
BOOST_AUTO_TEST_CASE( SHAMapSync_test ) BOOST_AUTO_TEST_CASE( SHAMapSync_test )
{ {
cLog(lsTRACE) << "begin sync test"; WriteLog (lsTRACE, SHAMap) << "begin sync test";
unsigned int seed; unsigned int seed;
RAND_pseudo_bytes(reinterpret_cast<unsigned char *>(&seed), sizeof(seed)); RAND_pseudo_bytes(reinterpret_cast<unsigned char *>(&seed), sizeof(seed));
srand(seed); srand(seed);
cLog(lsTRACE) << "Constructing maps"; WriteLog (lsTRACE, SHAMap) << "Constructing maps";
SHAMap source(smtFREE), destination(smtFREE); SHAMap source(smtFREE), destination(smtFREE);
// add random data to the source map // add random data to the source map
cLog(lsTRACE) << "Adding random data"; WriteLog (lsTRACE, SHAMap) << "Adding random data";
int items = 10000; int items = 10000;
for (int i = 0; i < items; ++i) for (int i = 0; i < items; ++i)
source.addItem(*makeRandomAS(), false, false); source.addItem(*makeRandomAS(), false, false);
cLog(lsTRACE) << "Adding items, then removing them"; WriteLog (lsTRACE, SHAMap) << "Adding items, then removing them";
if (!confuseMap(source, 500)) BOOST_FAIL("ConfuseMap"); if (!confuseMap(source, 500)) BOOST_FAIL("ConfuseMap");
source.setImmutable(); source.setImmutable();
cLog(lsTRACE) << "SOURCE COMPLETE, SYNCHING"; WriteLog (lsTRACE, SHAMap) << "SOURCE COMPLETE, SYNCHING";
std::vector<SHAMapNode> nodeIDs, gotNodeIDs; std::vector<SHAMapNode> nodeIDs, gotNodeIDs;
std::list< std::vector<unsigned char> > gotNodes; std::list< std::vector<unsigned char> > gotNodes;
@@ -625,24 +623,24 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0)) if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0))
{ {
cLog(lsFATAL) << "GetNodeFat(root) fails"; WriteLog (lsFATAL, SHAMap) << "GetNodeFat(root) fails";
BOOST_FAIL("GetNodeFat"); BOOST_FAIL("GetNodeFat");
} }
if (gotNodes.size() < 1) if (gotNodes.size() < 1)
{ {
cLog(lsFATAL) << "Didn't get root node " << gotNodes.size(); WriteLog (lsFATAL, SHAMap) << "Didn't get root node " << gotNodes.size();
BOOST_FAIL("NodeSize"); BOOST_FAIL("NodeSize");
} }
if (!destination.addRootNode(*gotNodes.begin(), snfWIRE, NULL)) if (!destination.addRootNode(*gotNodes.begin(), snfWIRE, NULL))
{ {
cLog(lsFATAL) << "AddRootNode fails"; WriteLog (lsFATAL, SHAMap) << "AddRootNode fails";
BOOST_FAIL("AddRootNode"); BOOST_FAIL("AddRootNode");
} }
nodeIDs.clear(); nodeIDs.clear();
gotNodes.clear(); gotNodes.clear();
cLog(lsINFO) << "ROOT COMPLETE, INNER SYNCHING"; WriteLog (lsINFO, SHAMap) << "ROOT COMPLETE, INNER SYNCHING";
#ifdef SMS_DEBUG #ifdef SMS_DEBUG
int bytes = 0; int bytes = 0;
#endif #endif
@@ -656,14 +654,14 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
destination.getMissingNodes(nodeIDs, hashes, 2048, NULL); destination.getMissingNodes(nodeIDs, hashes, 2048, NULL);
if (nodeIDs.empty()) break; if (nodeIDs.empty()) break;
cLog(lsINFO) << nodeIDs.size() << " needed nodes"; WriteLog (lsINFO, SHAMap) << nodeIDs.size() << " needed nodes";
// get as many nodes as possible based on this information // get as many nodes as possible based on this information
for (nodeIDIterator = nodeIDs.begin(); nodeIDIterator != nodeIDs.end(); ++nodeIDIterator) for (nodeIDIterator = nodeIDs.begin(); nodeIDIterator != nodeIDs.end(); ++nodeIDIterator)
{ {
if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0)) if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0))
{ {
cLog(lsFATAL) << "GetNodeFat fails"; WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails";
BOOST_FAIL("GetNodeFat"); BOOST_FAIL("GetNodeFat");
} }
} }
@@ -673,11 +671,11 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
if (gotNodeIDs.empty()) if (gotNodeIDs.empty())
{ {
cLog(lsFATAL) << "No nodes gotten"; WriteLog (lsFATAL, SHAMap) << "No nodes gotten";
BOOST_FAIL("Got Node ID"); BOOST_FAIL("Got Node ID");
} }
cLog(lsTRACE) << gotNodeIDs.size() << " found nodes"; WriteLog (lsTRACE, SHAMap) << gotNodeIDs.size() << " found nodes";
for (nodeIDIterator = gotNodeIDs.begin(), rawNodeIterator = gotNodes.begin(); for (nodeIDIterator = gotNodeIDs.begin(), rawNodeIterator = gotNodes.begin();
nodeIDIterator != gotNodeIDs.end(); ++nodeIDIterator, ++rawNodeIterator) nodeIDIterator != gotNodeIDs.end(); ++nodeIDIterator, ++rawNodeIterator)
{ {
@@ -687,7 +685,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
#endif #endif
if (!destination.addKnownNode(*nodeIDIterator, *rawNodeIterator, NULL)) if (!destination.addKnownNode(*nodeIDIterator, *rawNodeIterator, NULL))
{ {
cLog(lsTRACE) << "AddKnownNode fails"; WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails";
BOOST_FAIL("AddKnownNode"); BOOST_FAIL("AddKnownNode");
} }
} }
@@ -699,18 +697,18 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
destination.clearSynching(); destination.clearSynching();
#ifdef SMS_DEBUG #ifdef SMS_DEBUG
cLog(lsINFO) << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " << WriteLog (lsINFO) << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " <<
bytes / 1024 << " KB"; bytes / 1024 << " KB";
#endif #endif
if (!source.deepCompare(destination)) if (!source.deepCompare(destination))
{ {
cLog(lsFATAL) << "DeepCompare fails"; WriteLog (lsFATAL, SHAMap) << "DeepCompare fails";
BOOST_FAIL("Deep Compare"); BOOST_FAIL("Deep Compare");
} }
#ifdef SMS_DEBUG #ifdef SMS_DEBUG
cLog(lsINFO) << "SHAMapSync test passed: " << items << " items, " << WriteLog (lsINFO) << "SHAMapSync test passed: " << items << " items, " <<
passes << " passes, " << nodes << " nodes"; passes << " passes, " << nodes << " nodes";
#endif #endif