mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 03:55:53 +00:00
Fix platform and debug macros
This commit is contained in:
@@ -145,12 +145,12 @@
|
|||||||
<Filter Include="1. Modules\ripple_app\version">
|
<Filter Include="1. Modules\ripple_app\version">
|
||||||
<UniqueIdentifier>{a99a2905-0d36-40c0-84f5-06db41e48367}</UniqueIdentifier>
|
<UniqueIdentifier>{a99a2905-0d36-40c0-84f5-06db41e48367}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="1. Modules\ripple_app\peer">
|
|
||||||
<UniqueIdentifier>{9c76b354-fcca-412c-8b5b-cae084a1d91a}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="1. Modules\ripple_app\data">
|
<Filter Include="1. Modules\ripple_app\data">
|
||||||
<UniqueIdentifier>{6097a179-ddad-4c69-9a34-2e3fc2c9fa1d}</UniqueIdentifier>
|
<UniqueIdentifier>{6097a179-ddad-4c69-9a34-2e3fc2c9fa1d}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="1. Modules\ripple_app\peers">
|
||||||
|
<UniqueIdentifier>{9c76b354-fcca-412c-8b5b-cae084a1d91a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\src\cpp\protobuf_core.cpp">
|
<ClCompile Include="..\..\src\cpp\protobuf_core.cpp">
|
||||||
@@ -916,13 +916,13 @@
|
|||||||
<Filter>1. Modules\ripple_app\transactions</Filter>
|
<Filter>1. Modules\ripple_app\transactions</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peers.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peers.cpp">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_PeerSet.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_PeerSet.cpp">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObject.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObject.cpp">
|
||||||
<Filter>1. Modules\ripple_app\data</Filter>
|
<Filter>1. Modules\ripple_app\data</Filter>
|
||||||
@@ -940,7 +940,7 @@
|
|||||||
<Filter>1. Modules\ripple_app\main</Filter>
|
<Filter>1. Modules\ripple_app\main</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -1756,16 +1756,16 @@
|
|||||||
<Filter>1. Modules\ripple_app\transactions</Filter>
|
<Filter>1. Modules\ripple_app\transactions</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IProofOfWorkFactory.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_IProofOfWorkFactory.h">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IPeers.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_IPeers.h">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Peer.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_Peer.h">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PeerSet.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_PeerSet.h">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObject.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObject.h">
|
||||||
<Filter>1. Modules\ripple_app\data</Filter>
|
<Filter>1. Modules\ripple_app\data</Filter>
|
||||||
@@ -1780,7 +1780,7 @@
|
|||||||
<Filter>1. Modules\ripple_app\main</Filter>
|
<Filter>1. Modules\ripple_app\main</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IUniqueNodeList.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_IUniqueNodeList.h">
|
||||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (argc == 1 || !strcmp(argv[i],"-"))
|
if (argc == 1 || !strcmp(argv[i],"-"))
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
_setmode(_fileno(stdin), _O_BINARY);
|
_setmode(_fileno(stdin), _O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if BEAST_WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace boost
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ByteOrder
|
// ByteOrder
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
// (nothing)
|
// (nothing)
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
# include <libkern/OSByteOrder.h>
|
# include <libkern/OSByteOrder.h>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
|
|
||||||
// from: http://stackoverflow.com/questions/3022552/is-there-any-standard-htonl-like-function-for-64-bits-integers-in-c
|
// from: http://stackoverflow.com/questions/3022552/is-there-any-standard-htonl-like-function-for-64-bits-integers-in-c
|
||||||
// but we don't need to check the endianness
|
// but we don't need to check the endianness
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
// Reference: http://www.mail-archive.com/licq-commits@googlegroups.com/msg02334.html
|
// Reference: http://www.mail-archive.com/licq-commits@googlegroups.com/msg02334.html
|
||||||
|
|
||||||
// VFALCO TODO use BEAST_* platform macros instead of hard-coded compiler specific ones
|
#if BEAST_WIN32
|
||||||
#ifdef WIN32
|
|
||||||
extern uint64_t htobe64 (uint64_t value);
|
extern uint64_t htobe64 (uint64_t value);
|
||||||
extern uint64_t be64toh (uint64_t value);
|
extern uint64_t be64toh (uint64_t value);
|
||||||
extern uint32_t htobe32 (uint32_t value);
|
extern uint32_t htobe32 (uint32_t value);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ inline uint160 Hash160 (Blob const& vch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
// This is used to attempt to keep keying material out of swap
|
// This is used to attempt to keep keying material out of swap
|
||||||
// Note that VirtualLock does not provide this as a guarantee on Windows,
|
// Note that VirtualLock does not provide this as a guarantee on Windows,
|
||||||
// but, in practice, memory that has been VirtualLock'd almost never gets written to
|
// but, in practice, memory that has been VirtualLock'd almost never gets written to
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ RandomNumbers& RandomNumbers::getInstance ()
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// VFALCO TODO replace WIN32 macro with BEAST_WIN32
|
#if BEAST_WIN32
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Get entropy from the Windows crypto provider
|
// Get entropy from the Windows crypto provider
|
||||||
bool RandomNumbers::platformAddEntropy ()
|
bool RandomNumbers::platformAddEntropy ()
|
||||||
@@ -75,7 +74,7 @@ bool RandomNumbers::platformAddEntropy ()
|
|||||||
|
|
||||||
if (!CryptGetDefaultProviderA (PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, name, &count))
|
if (!CryptGetDefaultProviderA (PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, name, &count))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Unable to get default crypto provider" << std::endl;
|
std::cerr << "Unable to get default crypto provider" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@@ -83,7 +82,7 @@ bool RandomNumbers::platformAddEntropy ()
|
|||||||
|
|
||||||
if (!CryptAcquireContextA (&cryptoHandle, NULL, name, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
if (!CryptAcquireContextA (&cryptoHandle, NULL, name, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Unable to acquire crypto provider" << std::endl;
|
std::cerr << "Unable to acquire crypto provider" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@@ -91,7 +90,7 @@ bool RandomNumbers::platformAddEntropy ()
|
|||||||
|
|
||||||
if (!CryptGenRandom (cryptoHandle, 128, reinterpret_cast<BYTE*> (rand)))
|
if (!CryptGenRandom (cryptoHandle, 128, reinterpret_cast<BYTE*> (rand)))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Unable to get entropy from crypto provider" << std::endl;
|
std::cerr << "Unable to get entropy from crypto provider" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
CryptReleaseContext (cryptoHandle, 0);
|
CryptReleaseContext (cryptoHandle, 0);
|
||||||
@@ -115,7 +114,7 @@ bool RandomNumbers::platformAddEntropy ()
|
|||||||
|
|
||||||
if (!reader.is_open ())
|
if (!reader.is_open ())
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Unable to open random source" << std::endl;
|
std::cerr << "Unable to open random source" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +126,7 @@ bool RandomNumbers::platformAddEntropy ()
|
|||||||
|
|
||||||
if (bytesRead == 0)
|
if (bytesRead == 0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Unable to read from random source" << std::endl;
|
std::cerr << "Unable to read from random source" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@@ -170,7 +169,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
|||||||
int64 operator () () const
|
int64 operator () () const
|
||||||
{
|
{
|
||||||
int64 nCounter = 0;
|
int64 nCounter = 0;
|
||||||
#if defined(WIN32) || defined(WIN64)
|
#if BEAST_WIN32
|
||||||
QueryPerformanceCounter ((LARGE_INTEGER*)&nCounter);
|
QueryPerformanceCounter ((LARGE_INTEGER*)&nCounter);
|
||||||
#else
|
#else
|
||||||
timeval t;
|
timeval t;
|
||||||
@@ -198,7 +197,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
|||||||
|
|
||||||
nLastPerfmon = GetTime ();
|
nLastPerfmon = GetTime ();
|
||||||
|
|
||||||
#ifdef WIN32
|
#if BEAST_WIN32
|
||||||
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
||||||
// Seed with the entire set of perfmon data
|
// Seed with the entire set of perfmon data
|
||||||
unsigned char pdata[250000];
|
unsigned char pdata[250000];
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
// VFALCO TODO Repalce these with something more robust and without macros.
|
// VFALCO TODO Replace these with something more robust and without macros.
|
||||||
//
|
//
|
||||||
#if !defined(WIN32) && !defined(WIN64)
|
#if ! BEAST_MSVC
|
||||||
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ PackedMessage::PackedMessage (::google::protobuf::Message const& message, int ty
|
|||||||
{
|
{
|
||||||
message.SerializeToArray (&mBuffer [PackedMessage::kHeaderBytes], messageBytes);
|
message.SerializeToArray (&mBuffer [PackedMessage::kHeaderBytes], messageBytes);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
// std::cerr << "PackedMessage: type=" << type << ", datalen=" << msg_size << std::endl;
|
// std::cerr << "PackedMessage: type=" << type << ", datalen=" << msg_size << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ bool Ledger::hasAccount (const RippleAddress& accountID)
|
|||||||
|
|
||||||
AccountState::pointer Ledger::getAccountState (const RippleAddress& accountID)
|
AccountState::pointer Ledger::getAccountState (const RippleAddress& accountID)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
// std::cerr << "Ledger:getAccountState(" << accountID.humanAccountID() << ")" << std::endl;
|
// std::cerr << "Ledger:getAccountState(" << accountID.humanAccountID() << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
|
|||||||
else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||||
getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
|
getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
|
|
||||||
if (r != tesSUCCESS)
|
if (r != tesSUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2000,7 +2000,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
|||||||
uLedgerMin = uLedgerMax = l->getLedgerSeq ();
|
uLedgerMin = uLedgerMax = l->getLedgerSeq ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef BEAST_DEBUG
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -2066,7 +2066,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
|||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#ifndef DEBUG
|
#ifndef BEAST_DEBUG
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans
|
|||||||
assert (mLedger);
|
assert (mLedger);
|
||||||
mNodes.init (mLedger, txn.getTransactionID (), mLedger->getLedgerSeq (), params);
|
mNodes.init (mLedger, txn.getTransactionID (), mLedger->getLedgerSeq (), params);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ void Application::setup ()
|
|||||||
|
|
||||||
m_loadManager->startThread ();
|
m_loadManager->startThread ();
|
||||||
|
|
||||||
#ifndef WIN32
|
#if ! BEAST_WIN32
|
||||||
#ifdef SIGINT
|
#ifdef SIGINT
|
||||||
|
|
||||||
if (!theConfig.RUN_STANDALONE)
|
if (!theConfig.RUN_STANDALONE)
|
||||||
@@ -385,7 +385,7 @@ void Application::setup ()
|
|||||||
|
|
||||||
if (!theConfig.DEBUG_LOGFILE.empty ())
|
if (!theConfig.DEBUG_LOGFILE.empty ())
|
||||||
{
|
{
|
||||||
// Let DEBUG messages go to the file but only WARNING or higher to regular output (unless verbose)
|
// Let BEAST_DEBUG messages go to the file but only WARNING or higher to regular output (unless verbose)
|
||||||
Log::setLogFile (theConfig.DEBUG_LOGFILE);
|
Log::setLogFile (theConfig.DEBUG_LOGFILE);
|
||||||
|
|
||||||
if (Log::getMinSeverity () > lsDEBUG)
|
if (Log::getMinSeverity () > lsDEBUG)
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef RIPPLE_IUNIQUENODELIST_H
|
#ifndef RIPPLE_IUNIQUENODELIST_H_INCLUDED
|
||||||
#define RIPPLE_IUNIQUENODELIST_H
|
#define RIPPLE_IUNIQUENODELIST_H_INCLUDED
|
||||||
|
|
||||||
class IUniqueNodeList
|
class IUniqueNodeList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef enum
|
enum ValidatorSource
|
||||||
{
|
{
|
||||||
vsConfig = 'C', // rippled.cfg
|
vsConfig = 'C', // rippled.cfg
|
||||||
vsInbound = 'I',
|
vsInbound = 'I',
|
||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
vsTold = 'T',
|
vsTold = 'T',
|
||||||
vsValidator = 'V', // validators.txt
|
vsValidator = 'V', // validators.txt
|
||||||
vsWeb = 'W',
|
vsWeb = 'W',
|
||||||
} validatorSource;
|
};
|
||||||
|
|
||||||
// VFALCO TODO rename this to use the right coding style
|
// VFALCO TODO rename this to use the right coding style
|
||||||
typedef long score;
|
typedef long score;
|
||||||
@@ -34,8 +34,8 @@ public:
|
|||||||
virtual void start () = 0;
|
virtual void start () = 0;
|
||||||
|
|
||||||
// VFALCO TODO rename all these, the "node" prefix is redundant (lol)
|
// VFALCO TODO rename all these, the "node" prefix is redundant (lol)
|
||||||
virtual void nodeAddPublic (const RippleAddress& naNodePublic, validatorSource vsWhy, const std::string& strComment) = 0;
|
virtual void nodeAddPublic (const RippleAddress& naNodePublic, ValidatorSource vsWhy, const std::string& strComment) = 0;
|
||||||
virtual void nodeAddDomain (std::string strDomain, validatorSource vsWhy, const std::string& strComment = "") = 0;
|
virtual void nodeAddDomain (std::string strDomain, ValidatorSource vsWhy, const std::string& strComment = "") = 0;
|
||||||
virtual void nodeRemovePublic (const RippleAddress& naNodePublic) = 0;
|
virtual void nodeRemovePublic (const RippleAddress& naNodePublic) = 0;
|
||||||
virtual void nodeRemoveDomain (std::string strDomain) = 0;
|
virtual void nodeRemoveDomain (std::string strDomain) = 0;
|
||||||
virtual void nodeReset () = 0;
|
virtual void nodeReset () = 0;
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual Json::Value getUnlJson () = 0;
|
virtual Json::Value getUnlJson () = 0;
|
||||||
|
|
||||||
virtual int iSourceScore (validatorSource vsWhy) = 0;
|
virtual int iSourceScore (ValidatorSource vsWhy) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ private:
|
|||||||
bool mCluster; // Node in our cluster
|
bool mCluster; // Node in our cluster
|
||||||
RippleAddress mNodePublic; // Node public key of peer.
|
RippleAddress mNodePublic; // Node public key of peer.
|
||||||
std::string mNodeName;
|
std::string mNodeName;
|
||||||
ipPort mIpPort;
|
IPAndPortNumber mIpPort;
|
||||||
ipPort mIpPortConnect;
|
IPAndPortNumber mIpPortConnect;
|
||||||
uint256 mCookieHash;
|
uint256 mCookieHash;
|
||||||
uint64 mPeerId;
|
uint64 mPeerId;
|
||||||
bool mPrivate; // Keep peer IP private.
|
bool mPrivate; // Keep peer IP private.
|
||||||
@@ -213,7 +213,7 @@ PeerImp::PeerImp (boost::asio::io_service& io_service, boost::asio::ssl::context
|
|||||||
void PeerImp::handleWrite (const boost::system::error_code& error, size_t bytes_transferred)
|
void PeerImp::handleWrite (const boost::system::error_code& error, size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
// Call on IO strand
|
// Call on IO strand
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
// if (!error)
|
// if (!error)
|
||||||
// std::cerr << "PeerImp::handleWrite bytes: "<< bytes_transferred << std::endl;
|
// std::cerr << "PeerImp::handleWrite bytes: "<< bytes_transferred << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -640,7 +640,7 @@ void PeerImp::processReadBuffer ()
|
|||||||
{
|
{
|
||||||
// must not hold peer lock
|
// must not hold peer lock
|
||||||
int type = PackedMessage::getType (mReadbuf);
|
int type = PackedMessage::getType (mReadbuf);
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
// std::cerr << "PRB(" << type << "), len=" << (mReadbuf.size()-PackedMessage::kHeaderBytes) << std::endl;
|
// std::cerr << "PRB(" << type << "), len=" << (mReadbuf.size()-PackedMessage::kHeaderBytes) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -924,7 +924,7 @@ void PeerImp::recvHello (protocol::TMHello& packet)
|
|||||||
uint32 minTime = ourTime - 20;
|
uint32 minTime = ourTime - 20;
|
||||||
uint32 maxTime = ourTime + 20;
|
uint32 maxTime = ourTime + 20;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
|
|
||||||
if (packet.has_nettime ())
|
if (packet.has_nettime ())
|
||||||
{
|
{
|
||||||
@@ -1135,7 +1135,7 @@ void PeerImp::recvTransaction (protocol::TMTransaction& packet, ScopedLock& Mast
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Transaction from peer fails validity tests" << std::endl;
|
std::cerr << "Transaction from peer fails validity tests" << std::endl;
|
||||||
Json::StyledStreamWriter w;
|
Json::StyledStreamWriter w;
|
||||||
w.write (std::cerr, tx->getJson (0));
|
w.write (std::cerr, tx->getJson (0));
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
#define RIPPLE_PEER_H_INCLUDED
|
#define RIPPLE_PEER_H_INCLUDED
|
||||||
|
|
||||||
// VFALCO TODO Couldn't this be a struct?
|
// VFALCO TODO Couldn't this be a struct?
|
||||||
typedef std::pair <std::string, int> ipPort;
|
typedef std::pair <std::string, int> IPAndPortNumber;
|
||||||
|
|
||||||
|
/** Represents a peer connection in the overlay.
|
||||||
|
*/
|
||||||
class Peer
|
class Peer
|
||||||
: public boost::enable_shared_from_this <Peer>
|
: public boost::enable_shared_from_this <Peer>
|
||||||
, LeakChecked <Peer>
|
, LeakChecked <Peer>
|
||||||
|
|||||||
@@ -88,15 +88,15 @@ private:
|
|||||||
int mPhase;
|
int mPhase;
|
||||||
|
|
||||||
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
|
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
|
||||||
typedef std::pair<ipPort, Peer::pointer> pipPeer;
|
typedef std::pair<IPAndPortNumber, Peer::pointer> pipPeer;
|
||||||
typedef std::map<ipPort, Peer::pointer>::value_type vtPeer;
|
typedef std::map<IPAndPortNumber, Peer::pointer>::value_type vtPeer;
|
||||||
|
|
||||||
// Peers we are connecting with and non-thin peers we are connected to.
|
// Peers we are connecting with and non-thin peers we are connected to.
|
||||||
// Only peers we know the connection ip for are listed.
|
// Only peers we know the connection ip for are listed.
|
||||||
// We know the ip and port for:
|
// We know the ip and port for:
|
||||||
// - All outbound connections
|
// - All outbound connections
|
||||||
// - Some inbound connections (which we figured out).
|
// - Some inbound connections (which we figured out).
|
||||||
boost::unordered_map<ipPort, Peer::pointer> mIpMap;
|
boost::unordered_map<IPAndPortNumber, Peer::pointer> mIpMap;
|
||||||
|
|
||||||
// Non-thin peers which we are connected to.
|
// Non-thin peers which we are connected to.
|
||||||
// Peers we have the public key for.
|
// Peers we have the public key for.
|
||||||
@@ -171,16 +171,16 @@ bool Peers::savePeer (const std::string& strIp, int iPort, char code)
|
|||||||
|
|
||||||
Database* db = getApp().getWalletDB ()->getDB ();
|
Database* db = getApp().getWalletDB ()->getDB ();
|
||||||
|
|
||||||
std::string ipPort = sqlEscape (str (boost::format ("%s %d") % strIp % iPort));
|
std::string ipAndPort = sqlEscape (str (boost::format ("%s %d") % strIp % iPort));
|
||||||
|
|
||||||
ScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
ScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||||
std::string sql = str (boost::format ("SELECT COUNT(*) FROM PeerIps WHERE IpPort=%s;") % ipPort);
|
std::string sql = str (boost::format ("SELECT COUNT(*) FROM PeerIps WHERE IpPort=%s;") % ipAndPort);
|
||||||
|
|
||||||
if (db->executeSQL (sql) && db->startIterRows ())
|
if (db->executeSQL (sql) && db->startIterRows ())
|
||||||
{
|
{
|
||||||
if (!db->getInt (0))
|
if (!db->getInt (0))
|
||||||
{
|
{
|
||||||
db->executeSQL (str (boost::format ("INSERT INTO PeerIps (IpPort,Score,Source) values (%s,0,'%c');") % ipPort % code));
|
db->executeSQL (str (boost::format ("INSERT INTO PeerIps (IpPort,Score,Source) values (%s,0,'%c');") % ipAndPort % code));
|
||||||
bNew = true;
|
bNew = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -416,7 +416,7 @@ void Peers::connectTo (const std::string& strIp, int iPort)
|
|||||||
// <-- true, if already connected.
|
// <-- true, if already connected.
|
||||||
Peer::pointer Peers::peerConnect (const std::string& strIp, int iPort)
|
Peer::pointer Peers::peerConnect (const std::string& strIp, int iPort)
|
||||||
{
|
{
|
||||||
ipPort pipPeer = make_pair (strIp, iPort);
|
IPAndPortNumber pipPeer = make_pair (strIp, iPort);
|
||||||
Peer::pointer ppResult;
|
Peer::pointer ppResult;
|
||||||
|
|
||||||
|
|
||||||
@@ -648,7 +648,7 @@ bool Peers::peerScanSet (const std::string& strIp, int iPort)
|
|||||||
// --> strIp: not empty
|
// --> strIp: not empty
|
||||||
void Peers::peerClosed (Peer::ref peer, const std::string& strIp, int iPort)
|
void Peers::peerClosed (Peer::ref peer, const std::string& strIp, int iPort)
|
||||||
{
|
{
|
||||||
ipPort ipPeer = make_pair (strIp, iPort);
|
IPAndPortNumber ipPeer = make_pair (strIp, iPort);
|
||||||
bool bScanRefresh = false;
|
bool bScanRefresh = false;
|
||||||
|
|
||||||
// If the connection was our scan, we are no longer scanning.
|
// If the connection was our scan, we are no longer scanning.
|
||||||
@@ -664,7 +664,7 @@ void Peers::peerClosed (Peer::ref peer, const std::string& strIp, int iPort)
|
|||||||
bool bRedundant = true;
|
bool bRedundant = true;
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl (mPeerLock);
|
boost::recursive_mutex::scoped_lock sl (mPeerLock);
|
||||||
const boost::unordered_map<ipPort, Peer::pointer>::iterator& itIp = mIpMap.find (ipPeer);
|
const boost::unordered_map<IPAndPortNumber, Peer::pointer>::iterator& itIp = mIpMap.find (ipPeer);
|
||||||
|
|
||||||
if (itIp == mIpMap.end ())
|
if (itIp == mIpMap.end ())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& ha
|
|||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
|
|
||||||
if (node->getNodeHash () != hash)
|
if (node->getNodeHash () != hash)
|
||||||
{
|
{
|
||||||
@@ -925,7 +925,7 @@ int SHAMap::flushDirty (DirtyMap& map, int maxNodes, HashedObjectType t, uint32
|
|||||||
s.erase ();
|
s.erase ();
|
||||||
it->second->addRaw (s, snfPREFIX);
|
it->second->addRaw (s, snfPREFIX);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
|
|
||||||
if (s.getSHA512Half () != it->second->getNodeHash ())
|
if (s.getSHA512Half () != it->second->getNodeHash ())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, SHANodeFormat format,
|
|||||||
if (!node)
|
if (!node)
|
||||||
return SHAMapAddNode::invalid ();
|
return SHAMapAddNode::invalid ();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
node->dump ();
|
node->dump ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
#define SMS_DEBUG
|
#define SMS_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, uint3
|
|||||||
|
|
||||||
if ((type < 0) || (type > 4))
|
if ((type < 0) || (type > 4))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
std::cerr << "Invalid wire format node" << std::endl;
|
std::cerr << "Invalid wire format node" << std::endl;
|
||||||
std::cerr << strHex (rawNode) << std::endl;
|
std::cerr << strHex (rawNode) << std::endl;
|
||||||
assert (false);
|
assert (false);
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ bool SqliteDatabase::executeSQL (const char* sql, bool fail_ok)
|
|||||||
{
|
{
|
||||||
if (!fail_ok)
|
if (!fail_ok)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "Perror:" << mHost << ": " << rc;
|
WriteLog (lsWARNING, SqliteDatabase) << "Perror:" << mHost << ": " << rc;
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
||||||
@@ -137,7 +137,7 @@ bool SqliteDatabase::executeSQL (const char* sql, bool fail_ok)
|
|||||||
|
|
||||||
if (!fail_ok)
|
if (!fail_ok)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef BEAST_DEBUG
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "SQL Serror:" << mHost << ": " << rc;
|
WriteLog (lsWARNING, SqliteDatabase) << "SQL Serror:" << mHost << ": " << rc;
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
||||||
|
|||||||
@@ -24,24 +24,44 @@
|
|||||||
// VFALCO TODO move all function definitions inlined into the class.
|
// VFALCO TODO move all function definitions inlined into the class.
|
||||||
class UniqueNodeList : public IUniqueNodeList
|
class UniqueNodeList : public IUniqueNodeList
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
UniqueNodeList (boost::asio::io_service& io_service);
|
||||||
|
|
||||||
|
// Begin processing.
|
||||||
|
void start ();
|
||||||
|
|
||||||
|
void nodeAddPublic (const RippleAddress& naNodePublic, ValidatorSource vsWhy, const std::string& strComment);
|
||||||
|
void nodeAddDomain (std::string strDomain, ValidatorSource vsWhy, const std::string& strComment = "");
|
||||||
|
void nodeRemovePublic (const RippleAddress& naNodePublic);
|
||||||
|
void nodeRemoveDomain (std::string strDomain);
|
||||||
|
void nodeReset ();
|
||||||
|
|
||||||
|
void nodeScore ();
|
||||||
|
|
||||||
|
bool nodeInUNL (const RippleAddress& naNodePublic);
|
||||||
|
bool nodeInCluster (const RippleAddress& naNodePublic);
|
||||||
|
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name);
|
||||||
|
|
||||||
|
void nodeBootstrap ();
|
||||||
|
bool nodeLoad (boost::filesystem::path pConfig);
|
||||||
|
void nodeNetwork ();
|
||||||
|
|
||||||
|
Json::Value getUnlJson ();
|
||||||
|
|
||||||
|
int iSourceScore (ValidatorSource vsWhy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Misc persistent information
|
|
||||||
boost::posix_time::ptime mtpScoreUpdated;
|
|
||||||
boost::posix_time::ptime mtpFetchUpdated;
|
|
||||||
|
|
||||||
boost::recursive_mutex mUNLLock;
|
|
||||||
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
|
|
||||||
// XXX Contents needs to based on score.
|
|
||||||
boost::unordered_set<std::string> mUNL;
|
|
||||||
|
|
||||||
bool miscLoad ();
|
bool miscLoad ();
|
||||||
bool miscSave ();
|
bool miscSave ();
|
||||||
|
|
||||||
|
// VFALCO TODO Rename these structs? Are they objects with static storage?
|
||||||
|
// This looks like C and not C++...
|
||||||
|
//
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
std::string strDomain;
|
std::string strDomain;
|
||||||
RippleAddress naPublicKey;
|
RippleAddress naPublicKey;
|
||||||
validatorSource vsSource;
|
ValidatorSource vsSource;
|
||||||
boost::posix_time::ptime tpNext;
|
boost::posix_time::ptime tpNext;
|
||||||
boost::posix_time::ptime tpScan;
|
boost::posix_time::ptime tpScan;
|
||||||
boost::posix_time::ptime tpFetch;
|
boost::posix_time::ptime tpFetch;
|
||||||
@@ -52,7 +72,7 @@ private:
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
RippleAddress naPublicKey;
|
RippleAddress naPublicKey;
|
||||||
validatorSource vsSource;
|
ValidatorSource vsSource;
|
||||||
boost::posix_time::ptime tpNext;
|
boost::posix_time::ptime tpNext;
|
||||||
boost::posix_time::ptime tpScan;
|
boost::posix_time::ptime tpScan;
|
||||||
boost::posix_time::ptime tpFetch;
|
boost::posix_time::ptime tpFetch;
|
||||||
@@ -71,10 +91,8 @@ private:
|
|||||||
std::vector<int> viReferrals;
|
std::vector<int> viReferrals;
|
||||||
} scoreNode;
|
} scoreNode;
|
||||||
|
|
||||||
std::map<RippleAddress, std::string> sClusterNodes;
|
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string, int> strIndex;
|
typedef boost::unordered_map<std::string, int> strIndex;
|
||||||
typedef std::pair<std::string, int> ipPort;
|
typedef std::pair<std::string, int> IPAndPortNumber;
|
||||||
typedef boost::unordered_map<std::pair< std::string, int>, score> epScore;
|
typedef boost::unordered_map<std::pair< std::string, int>, score> epScore;
|
||||||
|
|
||||||
void trustedLoad ();
|
void trustedLoad ();
|
||||||
@@ -83,20 +101,10 @@ private:
|
|||||||
|
|
||||||
bool responseFetch (const std::string& strDomain, const boost::system::error_code& err, int iStatus, const std::string& strSiteFile);
|
bool responseFetch (const std::string& strDomain, const boost::system::error_code& err, int iStatus, const std::string& strSiteFile);
|
||||||
|
|
||||||
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
|
|
||||||
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.
|
|
||||||
boost::asio::deadline_timer mdtScoreTimer; // Timer to start scoring.
|
|
||||||
|
|
||||||
void scoreNext (bool bNow); // Update scoring timer.
|
void scoreNext (bool bNow); // Update scoring timer.
|
||||||
void scoreCompute ();
|
void scoreCompute ();
|
||||||
void scoreTimerHandler (const boost::system::error_code& err);
|
void scoreTimerHandler (const boost::system::error_code& err);
|
||||||
|
|
||||||
boost::mutex mFetchLock;
|
|
||||||
int mFetchActive; // Count of active fetches.
|
|
||||||
|
|
||||||
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
|
||||||
boost::asio::deadline_timer mdtFetchTimer; // Timer to start fetching.
|
|
||||||
|
|
||||||
void fetchNext ();
|
void fetchNext ();
|
||||||
void fetchDirty ();
|
void fetchDirty ();
|
||||||
void fetchFinish ();
|
void fetchFinish ();
|
||||||
@@ -109,7 +117,7 @@ private:
|
|||||||
bool responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, Section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile);
|
bool responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, Section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile);
|
||||||
|
|
||||||
void processIps (const std::string& strSite, const RippleAddress& naNodePublic, Section::mapped_type* pmtVecStrIps);
|
void processIps (const std::string& strSite, const RippleAddress& naNodePublic, Section::mapped_type* pmtVecStrIps);
|
||||||
int processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, Section::mapped_type* pmtVecStrValidators);
|
int processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, ValidatorSource vsWhy, Section::mapped_type* pmtVecStrValidators);
|
||||||
|
|
||||||
void processFile (const std::string& strDomain, const RippleAddress& naNodePublic, Section secSite);
|
void processFile (const std::string& strDomain, const RippleAddress& naNodePublic, Section secSite);
|
||||||
|
|
||||||
@@ -122,31 +130,27 @@ private:
|
|||||||
bool validatorsResponse (const boost::system::error_code& err, int iStatus, const std::string strResponse);
|
bool validatorsResponse (const boost::system::error_code& err, int iStatus, const std::string strResponse);
|
||||||
void nodeProcess (const std::string& strSite, const std::string& strValidators, const std::string& strSource);
|
void nodeProcess (const std::string& strSite, const std::string& strValidators, const std::string& strSource);
|
||||||
|
|
||||||
public:
|
private:
|
||||||
UniqueNodeList (boost::asio::io_service& io_service);
|
// Misc persistent information
|
||||||
|
boost::posix_time::ptime mtpScoreUpdated;
|
||||||
|
boost::posix_time::ptime mtpFetchUpdated;
|
||||||
|
|
||||||
// Begin processing.
|
boost::recursive_mutex mUNLLock;
|
||||||
void start ();
|
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
|
||||||
|
// XXX Contents needs to based on score.
|
||||||
|
boost::unordered_set<std::string> mUNL;
|
||||||
|
|
||||||
void nodeAddPublic (const RippleAddress& naNodePublic, validatorSource vsWhy, const std::string& strComment);
|
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
|
||||||
void nodeAddDomain (std::string strDomain, validatorSource vsWhy, const std::string& strComment = "");
|
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.
|
||||||
void nodeRemovePublic (const RippleAddress& naNodePublic);
|
boost::asio::deadline_timer mdtScoreTimer; // Timer to start scoring.
|
||||||
void nodeRemoveDomain (std::string strDomain);
|
|
||||||
void nodeReset ();
|
|
||||||
|
|
||||||
void nodeScore ();
|
boost::mutex mFetchLock;
|
||||||
|
int mFetchActive; // Count of active fetches.
|
||||||
|
|
||||||
bool nodeInUNL (const RippleAddress& naNodePublic);
|
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
||||||
bool nodeInCluster (const RippleAddress& naNodePublic);
|
boost::asio::deadline_timer mdtFetchTimer; // Timer to start fetching.
|
||||||
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name);
|
|
||||||
|
|
||||||
void nodeBootstrap ();
|
std::map<RippleAddress, std::string> sClusterNodes;
|
||||||
bool nodeLoad (boost::filesystem::path pConfig);
|
|
||||||
void nodeNetwork ();
|
|
||||||
|
|
||||||
Json::Value getUnlJson ();
|
|
||||||
|
|
||||||
int iSourceScore (validatorSource vsWhy);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// VFALCO TODO Replace macros with language constructs
|
// VFALCO TODO Replace macros with language constructs
|
||||||
@@ -347,7 +351,7 @@ void UniqueNodeList::scoreCompute ()
|
|||||||
std::string strDomain = db->getStrBinary ("Domain");
|
std::string strDomain = db->getStrBinary ("Domain");
|
||||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||||
std::string strSource = db->getStrBinary ("Source");
|
std::string strSource = db->getStrBinary ("Source");
|
||||||
int iScore = iSourceScore (static_cast<validatorSource> (strSource[0]));
|
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||||
|
|
||||||
if (siOld == umPulicIdx.end ())
|
if (siOld == umPulicIdx.end ())
|
||||||
@@ -393,7 +397,7 @@ void UniqueNodeList::scoreCompute ()
|
|||||||
{
|
{
|
||||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||||
std::string strSource = db->getStrBinary ("Source");
|
std::string strSource = db->getStrBinary ("Source");
|
||||||
int iScore = iSourceScore (static_cast<validatorSource> (strSource[0]));
|
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||||
|
|
||||||
if (siOld == umPulicIdx.end ())
|
if (siOld == umPulicIdx.end ())
|
||||||
@@ -654,7 +658,7 @@ void UniqueNodeList::scoreCompute ()
|
|||||||
typedef boost::unordered_map<std::pair< std::string, int>, score>::value_type ipScoreType;
|
typedef boost::unordered_map<std::pair< std::string, int>, score>::value_type ipScoreType;
|
||||||
BOOST_FOREACH (ipScoreType & ipScore, umScore)
|
BOOST_FOREACH (ipScoreType & ipScore, umScore)
|
||||||
{
|
{
|
||||||
ipPort ipEndpoint = ipScore.first;
|
IPAndPortNumber ipEndpoint = ipScore.first;
|
||||||
std::string strIpPort = str (boost::format ("%s %d") % ipEndpoint.first % ipEndpoint.second);
|
std::string strIpPort = str (boost::format ("%s %d") % ipEndpoint.first % ipEndpoint.second);
|
||||||
score iPoints = ipScore.second;
|
score iPoints = ipScore.second;
|
||||||
|
|
||||||
@@ -829,7 +833,7 @@ void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress
|
|||||||
// --> strValidatorsSrc: source details for display
|
// --> strValidatorsSrc: source details for display
|
||||||
// --> naNodePublic: remote source public key - not valid for local
|
// --> naNodePublic: remote source public key - not valid for local
|
||||||
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
|
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
|
||||||
int UniqueNodeList::processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, Section::mapped_type* pmtVecStrValidators)
|
int UniqueNodeList::processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, ValidatorSource vsWhy, Section::mapped_type* pmtVecStrValidators)
|
||||||
{
|
{
|
||||||
Database* db = getApp().getWalletDB ()->getDB ();
|
Database* db = getApp().getWalletDB ()->getDB ();
|
||||||
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
|
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
|
||||||
@@ -1304,7 +1308,7 @@ void UniqueNodeList::fetchNext ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For each kind of source, have a starting number of points to be distributed.
|
// For each kind of source, have a starting number of points to be distributed.
|
||||||
int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
int UniqueNodeList::iSourceScore (ValidatorSource vsWhy)
|
||||||
{
|
{
|
||||||
int iScore = 0;
|
int iScore = 0;
|
||||||
|
|
||||||
@@ -1339,7 +1343,7 @@ int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error ("Internal error: bad validatorSource.");
|
throw std::runtime_error ("Internal error: bad ValidatorSource.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return iScore;
|
return iScore;
|
||||||
@@ -1378,7 +1382,7 @@ bool UniqueNodeList::getSeedDomains (const std::string& strDomain, seedDomain& d
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string strSource = db->getStrBinary ("Source");
|
std::string strSource = db->getStrBinary ("Source");
|
||||||
dstSeedDomain.vsSource = static_cast<validatorSource> (strSource[0]);
|
dstSeedDomain.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||||
|
|
||||||
iNext = db->getInt ("Next");
|
iNext = db->getInt ("Next");
|
||||||
dstSeedDomain.tpNext = ptFromSeconds (iNext);
|
dstSeedDomain.tpNext = ptFromSeconds (iNext);
|
||||||
@@ -1444,7 +1448,7 @@ void UniqueNodeList::setSeedDomains (const seedDomain& sdSource, bool bNext)
|
|||||||
// Queue a domain for a single attempt fetch a ripple.txt.
|
// Queue a domain for a single attempt fetch a ripple.txt.
|
||||||
// --> strComment: only used on vsManual
|
// --> strComment: only used on vsManual
|
||||||
// YYY As a lot of these may happen at once, would be nice to wrap multiple calls in a transaction.
|
// YYY As a lot of these may happen at once, would be nice to wrap multiple calls in a transaction.
|
||||||
void UniqueNodeList::nodeAddDomain (std::string strDomain, validatorSource vsWhy, const std::string& strComment)
|
void UniqueNodeList::nodeAddDomain (std::string strDomain, ValidatorSource vsWhy, const std::string& strComment)
|
||||||
{
|
{
|
||||||
boost::trim (strDomain);
|
boost::trim (strDomain);
|
||||||
boost::to_lower (strDomain);
|
boost::to_lower (strDomain);
|
||||||
@@ -1517,7 +1521,7 @@ bool UniqueNodeList::getSeedNodes (const RippleAddress& naNodePublic, seedNode&
|
|||||||
}
|
}
|
||||||
|
|
||||||
strSource = db->getStrBinary ("Source");
|
strSource = db->getStrBinary ("Source");
|
||||||
dstSeedNode.vsSource = static_cast<validatorSource> (strSource[0]);
|
dstSeedNode.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||||
|
|
||||||
iNext = db->getInt ("Next");
|
iNext = db->getInt ("Next");
|
||||||
dstSeedNode.tpNext = ptFromSeconds (iNext);
|
dstSeedNode.tpNext = ptFromSeconds (iNext);
|
||||||
@@ -1592,7 +1596,7 @@ void UniqueNodeList::setSeedNodes (const seedNode& snSource, bool bNext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a trusted node. Called by RPC or other source.
|
// Add a trusted node. Called by RPC or other source.
|
||||||
void UniqueNodeList::nodeAddPublic (const RippleAddress& naNodePublic, validatorSource vsWhy, const std::string& strComment)
|
void UniqueNodeList::nodeAddPublic (const RippleAddress& naNodePublic, ValidatorSource vsWhy, const std::string& strComment)
|
||||||
{
|
{
|
||||||
seedNode snCurrent;
|
seedNode snCurrent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user