mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Fix platform and debug macros
This commit is contained in:
@@ -145,12 +145,12 @@
|
||||
<Filter Include="1. Modules\ripple_app\version">
|
||||
<UniqueIdentifier>{a99a2905-0d36-40c0-84f5-06db41e48367}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_app\peer">
|
||||
<UniqueIdentifier>{9c76b354-fcca-412c-8b5b-cae084a1d91a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_app\data">
|
||||
<UniqueIdentifier>{6097a179-ddad-4c69-9a34-2e3fc2c9fa1d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_app\peers">
|
||||
<UniqueIdentifier>{9c76b354-fcca-412c-8b5b-cae084a1d91a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\cpp\protobuf_core.cpp">
|
||||
@@ -916,13 +916,13 @@
|
||||
<Filter>1. Modules\ripple_app\transactions</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peers.cpp">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_PeerSet.cpp">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObject.cpp">
|
||||
<Filter>1. Modules\ripple_app\data</Filter>
|
||||
@@ -940,7 +940,7 @@
|
||||
<Filter>1. Modules\ripple_app\main</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -1756,16 +1756,16 @@
|
||||
<Filter>1. Modules\ripple_app\transactions</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IProofOfWorkFactory.h">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IPeers.h">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Peer.h">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PeerSet.h">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObject.h">
|
||||
<Filter>1. Modules\ripple_app\data</Filter>
|
||||
@@ -1780,7 +1780,7 @@
|
||||
<Filter>1. Modules\ripple_app\main</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IUniqueNodeList.h">
|
||||
<Filter>1. Modules\ripple_app\peer</Filter>
|
||||
<Filter>1. Modules\ripple_app\peers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc == 1 || !strcmp(argv[i],"-"))
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
#endif
|
||||
fp = stdin;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#if defined(WIN32)
|
||||
#if BEAST_WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace boost
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ByteOrder
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
// (nothing)
|
||||
#elif __APPLE__
|
||||
# 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
|
||||
// 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
|
||||
|
||||
// VFALCO TODO use BEAST_* platform macros instead of hard-coded compiler specific ones
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
extern uint64_t htobe64 (uint64_t value);
|
||||
extern uint64_t be64toh (uint64_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
|
||||
// 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
|
||||
|
||||
@@ -63,8 +63,7 @@ RandomNumbers& RandomNumbers::getInstance ()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// VFALCO TODO replace WIN32 macro with BEAST_WIN32
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
|
||||
// Get entropy from the Windows crypto provider
|
||||
bool RandomNumbers::platformAddEntropy ()
|
||||
@@ -75,7 +74,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
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;
|
||||
#endif
|
||||
return false;
|
||||
@@ -83,7 +82,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
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;
|
||||
#endif
|
||||
return false;
|
||||
@@ -91,7 +90,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!CryptGenRandom (cryptoHandle, 128, reinterpret_cast<BYTE*> (rand)))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to get entropy from crypto provider" << std::endl;
|
||||
#endif
|
||||
CryptReleaseContext (cryptoHandle, 0);
|
||||
@@ -115,7 +114,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!reader.is_open ())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to open random source" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -127,7 +126,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to read from random source" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -170,7 +169,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
||||
int64 operator () () const
|
||||
{
|
||||
int64 nCounter = 0;
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#if BEAST_WIN32
|
||||
QueryPerformanceCounter ((LARGE_INTEGER*)&nCounter);
|
||||
#else
|
||||
timeval t;
|
||||
@@ -198,7 +197,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
||||
|
||||
nLastPerfmon = GetTime ();
|
||||
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
||||
// Seed with the entire set of perfmon data
|
||||
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)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ PackedMessage::PackedMessage (::google::protobuf::Message const& message, int ty
|
||||
{
|
||||
message.SerializeToArray (&mBuffer [PackedMessage::kHeaderBytes], messageBytes);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
// std::cerr << "PackedMessage: type=" << type << ", datalen=" << msg_size << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ bool Ledger::hasAccount (const RippleAddress& accountID)
|
||||
|
||||
AccountState::pointer Ledger::getAccountState (const RippleAddress& accountID)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
// std::cerr << "Ledger:getAccountState(" << accountID.humanAccountID() << ")" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
|
||||
else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||
getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (r != tesSUCCESS)
|
||||
{
|
||||
|
||||
@@ -2000,7 +2000,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
||||
uLedgerMin = uLedgerMax = l->getLedgerSeq ();
|
||||
}
|
||||
|
||||
#ifndef DEBUG
|
||||
#ifndef BEAST_DEBUG
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2066,7 +2066,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
||||
|
||||
|
||||
return ret;
|
||||
#ifndef DEBUG
|
||||
#ifndef BEAST_DEBUG
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans
|
||||
assert (mLedger);
|
||||
mNodes.init (mLedger, txn.getTransactionID (), mLedger->getLedgerSeq (), params);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (1)
|
||||
{
|
||||
|
||||
@@ -367,7 +367,7 @@ void Application::setup ()
|
||||
|
||||
m_loadManager->startThread ();
|
||||
|
||||
#ifndef WIN32
|
||||
#if ! BEAST_WIN32
|
||||
#ifdef SIGINT
|
||||
|
||||
if (!theConfig.RUN_STANDALONE)
|
||||
@@ -385,7 +385,7 @@ void Application::setup ()
|
||||
|
||||
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);
|
||||
|
||||
if (Log::getMinSeverity () > lsDEBUG)
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_IUNIQUENODELIST_H
|
||||
#define RIPPLE_IUNIQUENODELIST_H
|
||||
#ifndef RIPPLE_IUNIQUENODELIST_H_INCLUDED
|
||||
#define RIPPLE_IUNIQUENODELIST_H_INCLUDED
|
||||
|
||||
class IUniqueNodeList
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
enum ValidatorSource
|
||||
{
|
||||
vsConfig = 'C', // rippled.cfg
|
||||
vsInbound = 'I',
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
vsTold = 'T',
|
||||
vsValidator = 'V', // validators.txt
|
||||
vsWeb = 'W',
|
||||
} validatorSource;
|
||||
};
|
||||
|
||||
// VFALCO TODO rename this to use the right coding style
|
||||
typedef long score;
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
virtual void start () = 0;
|
||||
|
||||
// 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 nodeAddDomain (std::string strDomain, 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 nodeRemovePublic (const RippleAddress& naNodePublic) = 0;
|
||||
virtual void nodeRemoveDomain (std::string strDomain) = 0;
|
||||
virtual void nodeReset () = 0;
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
virtual Json::Value getUnlJson () = 0;
|
||||
|
||||
virtual int iSourceScore (validatorSource vsWhy) = 0;
|
||||
virtual int iSourceScore (ValidatorSource vsWhy) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -116,8 +116,8 @@ private:
|
||||
bool mCluster; // Node in our cluster
|
||||
RippleAddress mNodePublic; // Node public key of peer.
|
||||
std::string mNodeName;
|
||||
ipPort mIpPort;
|
||||
ipPort mIpPortConnect;
|
||||
IPAndPortNumber mIpPort;
|
||||
IPAndPortNumber mIpPortConnect;
|
||||
uint256 mCookieHash;
|
||||
uint64 mPeerId;
|
||||
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)
|
||||
{
|
||||
// Call on IO strand
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
// if (!error)
|
||||
// std::cerr << "PeerImp::handleWrite bytes: "<< bytes_transferred << std::endl;
|
||||
#endif
|
||||
@@ -640,7 +640,7 @@ void PeerImp::processReadBuffer ()
|
||||
{
|
||||
// must not hold peer lock
|
||||
int type = PackedMessage::getType (mReadbuf);
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
// std::cerr << "PRB(" << type << "), len=" << (mReadbuf.size()-PackedMessage::kHeaderBytes) << std::endl;
|
||||
#endif
|
||||
|
||||
@@ -924,7 +924,7 @@ void PeerImp::recvHello (protocol::TMHello& packet)
|
||||
uint32 minTime = ourTime - 20;
|
||||
uint32 maxTime = ourTime + 20;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (packet.has_nettime ())
|
||||
{
|
||||
@@ -1135,7 +1135,7 @@ void PeerImp::recvTransaction (protocol::TMTransaction& packet, ScopedLock& Mast
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Transaction from peer fails validity tests" << std::endl;
|
||||
Json::StyledStreamWriter w;
|
||||
w.write (std::cerr, tx->getJson (0));
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#define RIPPLE_PEER_H_INCLUDED
|
||||
|
||||
// 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
|
||||
: public boost::enable_shared_from_this <Peer>
|
||||
, LeakChecked <Peer>
|
||||
|
||||
@@ -88,15 +88,15 @@ private:
|
||||
int mPhase;
|
||||
|
||||
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
|
||||
typedef std::pair<ipPort, Peer::pointer> pipPeer;
|
||||
typedef std::map<ipPort, Peer::pointer>::value_type vtPeer;
|
||||
typedef std::pair<IPAndPortNumber, Peer::pointer> pipPeer;
|
||||
typedef std::map<IPAndPortNumber, Peer::pointer>::value_type vtPeer;
|
||||
|
||||
// Peers we are connecting with and non-thin peers we are connected to.
|
||||
// Only peers we know the connection ip for are listed.
|
||||
// We know the ip and port for:
|
||||
// - All outbound connections
|
||||
// - 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.
|
||||
// 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 ();
|
||||
|
||||
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 ());
|
||||
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->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;
|
||||
}
|
||||
else
|
||||
@@ -416,7 +416,7 @@ void Peers::connectTo (const std::string& strIp, int iPort)
|
||||
// <-- true, if already connected.
|
||||
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;
|
||||
|
||||
|
||||
@@ -648,7 +648,7 @@ bool Peers::peerScanSet (const std::string& strIp, int iPort)
|
||||
// --> strIp: not empty
|
||||
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;
|
||||
|
||||
// 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;
|
||||
{
|
||||
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 ())
|
||||
{
|
||||
|
||||
@@ -208,7 +208,7 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& ha
|
||||
|
||||
if (node)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (node->getNodeHash () != hash)
|
||||
{
|
||||
@@ -925,7 +925,7 @@ int SHAMap::flushDirty (DirtyMap& map, int maxNodes, HashedObjectType t, uint32
|
||||
s.erase ();
|
||||
it->second->addRaw (s, snfPREFIX);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (s.getSHA512Half () != it->second->getNodeHash ())
|
||||
{
|
||||
|
||||
@@ -235,7 +235,7 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, SHANodeFormat format,
|
||||
if (!node)
|
||||
return SHAMapAddNode::invalid ();
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
node->dump ();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
#define SMS_DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, uint3
|
||||
|
||||
if ((type < 0) || (type > 4))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Invalid wire format node" << std::endl;
|
||||
std::cerr << strHex (rawNode) << std::endl;
|
||||
assert (false);
|
||||
|
||||
@@ -103,7 +103,7 @@ bool SqliteDatabase::executeSQL (const char* sql, bool fail_ok)
|
||||
{
|
||||
if (!fail_ok)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Perror:" << mHost << ": " << rc;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
||||
@@ -137,7 +137,7 @@ bool SqliteDatabase::executeSQL (const char* sql, bool fail_ok)
|
||||
|
||||
if (!fail_ok)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "SQL Serror:" << mHost << ": " << rc;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg (mConnection);
|
||||
|
||||
@@ -24,24 +24,44 @@
|
||||
// VFALCO TODO move all function definitions inlined into the class.
|
||||
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:
|
||||
// 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 miscSave ();
|
||||
|
||||
// VFALCO TODO Rename these structs? Are they objects with static storage?
|
||||
// This looks like C and not C++...
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
std::string strDomain;
|
||||
RippleAddress naPublicKey;
|
||||
validatorSource vsSource;
|
||||
ValidatorSource vsSource;
|
||||
boost::posix_time::ptime tpNext;
|
||||
boost::posix_time::ptime tpScan;
|
||||
boost::posix_time::ptime tpFetch;
|
||||
@@ -52,7 +72,7 @@ private:
|
||||
typedef struct
|
||||
{
|
||||
RippleAddress naPublicKey;
|
||||
validatorSource vsSource;
|
||||
ValidatorSource vsSource;
|
||||
boost::posix_time::ptime tpNext;
|
||||
boost::posix_time::ptime tpScan;
|
||||
boost::posix_time::ptime tpFetch;
|
||||
@@ -71,10 +91,8 @@ private:
|
||||
std::vector<int> viReferrals;
|
||||
} scoreNode;
|
||||
|
||||
std::map<RippleAddress, std::string> sClusterNodes;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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 scoreCompute ();
|
||||
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 fetchDirty ();
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
@@ -122,31 +130,27 @@ private:
|
||||
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);
|
||||
|
||||
public:
|
||||
UniqueNodeList (boost::asio::io_service& io_service);
|
||||
private:
|
||||
// Misc persistent information
|
||||
boost::posix_time::ptime mtpScoreUpdated;
|
||||
boost::posix_time::ptime mtpFetchUpdated;
|
||||
|
||||
// Begin processing.
|
||||
void start ();
|
||||
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;
|
||||
|
||||
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 ();
|
||||
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 nodeScore ();
|
||||
boost::mutex mFetchLock;
|
||||
int mFetchActive; // Count of active fetches.
|
||||
|
||||
bool nodeInUNL (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name);
|
||||
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
||||
boost::asio::deadline_timer mdtFetchTimer; // Timer to start fetching.
|
||||
|
||||
void nodeBootstrap ();
|
||||
bool nodeLoad (boost::filesystem::path pConfig);
|
||||
void nodeNetwork ();
|
||||
|
||||
Json::Value getUnlJson ();
|
||||
|
||||
int iSourceScore (validatorSource vsWhy);
|
||||
std::map<RippleAddress, std::string> sClusterNodes;
|
||||
};
|
||||
|
||||
// VFALCO TODO Replace macros with language constructs
|
||||
@@ -347,7 +351,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
std::string strDomain = db->getStrBinary ("Domain");
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
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);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
@@ -393,7 +397,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
{
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
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);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
@@ -654,7 +658,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
typedef boost::unordered_map<std::pair< std::string, int>, score>::value_type ipScoreType;
|
||||
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);
|
||||
score iPoints = ipScore.second;
|
||||
|
||||
@@ -829,7 +833,7 @@ void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress
|
||||
// --> strValidatorsSrc: source details for display
|
||||
// --> naNodePublic: remote source public key - not valid for local
|
||||
// --> 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 ();
|
||||
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.
|
||||
int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
||||
int UniqueNodeList::iSourceScore (ValidatorSource vsWhy)
|
||||
{
|
||||
int iScore = 0;
|
||||
|
||||
@@ -1339,7 +1343,7 @@ int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error ("Internal error: bad validatorSource.");
|
||||
throw std::runtime_error ("Internal error: bad ValidatorSource.");
|
||||
}
|
||||
|
||||
return iScore;
|
||||
@@ -1378,7 +1382,7 @@ bool UniqueNodeList::getSeedDomains (const std::string& strDomain, seedDomain& d
|
||||
}
|
||||
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
dstSeedDomain.vsSource = static_cast<validatorSource> (strSource[0]);
|
||||
dstSeedDomain.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||
|
||||
iNext = db->getInt ("Next");
|
||||
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.
|
||||
// --> 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.
|
||||
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::to_lower (strDomain);
|
||||
@@ -1517,7 +1521,7 @@ bool UniqueNodeList::getSeedNodes (const RippleAddress& naNodePublic, seedNode&
|
||||
}
|
||||
|
||||
strSource = db->getStrBinary ("Source");
|
||||
dstSeedNode.vsSource = static_cast<validatorSource> (strSource[0]);
|
||||
dstSeedNode.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||
|
||||
iNext = db->getInt ("Next");
|
||||
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.
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user