Add ripple_net module

This commit is contained in:
Vinnie Falco
2013-05-22 17:02:40 -07:00
parent a5360379ac
commit f4cb47fed6
12 changed files with 416 additions and 301 deletions

View File

@@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
/** Add this to get the @ref ripple_net module.
@file ripple_net.cpp
@ingroup ripple_net
*/
#include "ripple_net.h"
// 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/Application.h"
// This is for PeerDoor and WSDoor
// Generate DH for SSL connection.
static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
{
// VFALCO: TODO, eliminate this horrendous dependency on theApp and Wallet
return 512 == iKeyLength ? theApp->getWallet().getDh512() : theApp->getWallet().getDh1024();
}
#include "src/cpp/ripple/ConnectionPool.cpp"
#include "src/cpp/ripple/NetworkOPs.cpp"
#include "src/cpp/ripple/Peer.cpp"
#include "src/cpp/ripple/PeerDoor.cpp"
#include "src/cpp/ripple/WSDoor.cpp" // uses logging in WSConnection.h
#ifdef _MSC_VER
//#pragma warning (pop)
#endif

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
/** Include this to get the @ref ripple_net module.
@file ripple_net.h
@ingroup ripple_net
*/
/** Peer to peer overlay classes.
Contains classes that support the peer to peer overlay.
@defgroup ripple_net
*/
#ifndef RIPPLE_NET_H
#define RIPPLE_NET_H
#endif

View File

@@ -172,6 +172,7 @@
<ClCompile Include="modules\ripple_db\ripple_db.cpp" />
<ClCompile Include="modules\ripple_ledger\ripple_ledger.cpp" />
<ClCompile Include="modules\ripple_main\ripple_main.cpp" />
<ClCompile Include="modules\ripple_net\ripple_net.cpp" />
<ClCompile Include="src\cpp\database\database.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -595,7 +596,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ConnectionPool.cpp" />
<ClCompile Include="src\cpp\ripple\ConnectionPool.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\Contract.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -739,7 +745,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp" />
<ClCompile Include="src\cpp\ripple\NetworkOPs.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\NicknameState.cpp" />
<ClCompile Include="src\cpp\ripple\Offer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -803,8 +814,18 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Peer.cpp" />
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp" />
<ClCompile Include="src\cpp\ripple\Peer.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\PeerDoor.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\PFRequest.cpp" />
<ClCompile Include="src\cpp\ripple\PlatRand.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -1031,7 +1052,12 @@
</ClCompile>
<ClCompile Include="src\cpp\ripple\Wallet.cpp" />
<ClCompile Include="src\cpp\ripple\WalletAddTransactor.cpp" />
<ClCompile Include="src\cpp\ripple\WSDoor.cpp" />
<ClCompile Include="src\cpp\ripple\WSDoor.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\websocketpp\src\base64\base64.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1078,6 +1104,7 @@
<ClInclude Include="modules\ripple_db\ripple_db.h" />
<ClInclude Include="modules\ripple_ledger\ripple_ledger.h" />
<ClInclude Include="modules\ripple_main\ripple_main.h" />
<ClInclude Include="modules\ripple_net\ripple_net.h" />
<ClInclude Include="src\cpp\database\database.h" />
<ClInclude Include="src\cpp\database\SqliteDatabase.h" />
<ClInclude Include="src\cpp\json\autolink.h">

View File

@@ -107,6 +107,9 @@
<Filter Include="1. Modules\ripple_client\http">
<UniqueIdentifier>{29cd2103-d553-4d82-9e6a-224e3b1cb667}</UniqueIdentifier>
</Filter>
<Filter Include="1. Modules\ripple_net\sockets">
<UniqueIdentifier>{afd09812-59e2-45e2-bf7f-d561b23d7da2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\cpp\database\sqlite3.c">
@@ -436,15 +439,6 @@
<ClCompile Include="src\cpp\ripple\ripple.pb.cc">
<Filter>protoc_generated</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ConnectionPool.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Peer.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Transaction.cpp">
<Filter>1. Modules\ripple_ledger\transactions</Filter>
</ClCompile>
@@ -499,9 +493,6 @@
<ClCompile Include="src\cpp\ripple\Contract.cpp">
<Filter>1. Modules\ripple_ledger\contracts</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\SerializedLedger.cpp">
<Filter>1. Modules\ripple_ledger\serialization</Filter>
</ClCompile>
@@ -520,9 +511,6 @@
<ClCompile Include="src\cpp\ripple\Serializer.cpp">
<Filter>1. Modules\ripple_ledger\serialization</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\WSDoor.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Amount.cpp">
<Filter>1. Modules\ripple_basics\types</Filter>
</ClCompile>
@@ -718,6 +706,24 @@
<ClCompile Include="src\cpp\ripple\HTTPRequest.cpp">
<Filter>1. Modules\ripple_client\http</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ConnectionPool.cpp">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Peer.cpp">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\WSDoor.cpp">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClCompile>
<ClCompile Include="modules\ripple_net\ripple_net.cpp">
<Filter>1. Modules\ripple_net</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="database\sqlite3ext.h">
@@ -1074,18 +1080,6 @@
<ClInclude Include="src\cpp\ripple\ripple.pb.h">
<Filter>protoc_generated</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\AutoSocket.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ConnectionPool.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\PeerDoor.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\Peer.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\Transaction.h">
<Filter>1. Modules\ripple_ledger\transactions</Filter>
</ClInclude>
@@ -1134,9 +1128,6 @@
<ClInclude Include="src\cpp\ripple\Contract.h">
<Filter>1. Modules\ripple_ledger\contracts</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\NetworkOPs.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\SerializedLedger.h">
<Filter>1. Modules\ripple_ledger\serialization</Filter>
</ClInclude>
@@ -1158,12 +1149,6 @@
<ClInclude Include="src\cpp\ripple\Serializer.h">
<Filter>1. Modules\ripple_ledger\serialization</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\WSDoor.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\WSConnection.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\base58.h">
<Filter>1. Modules\ripple_basics\types</Filter>
</ClInclude>
@@ -1356,6 +1341,30 @@
<ClInclude Include="src\cpp\ripple\HTTPRequest.h">
<Filter>1. Modules\ripple_client\http</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\WSDoor.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\AutoSocket.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ConnectionPool.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\NetworkOPs.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\Peer.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\PeerDoor.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\WSConnection.h">
<Filter>1. Modules\ripple_net\sockets</Filter>
</ClInclude>
<ClInclude Include="modules\ripple_net\ripple_net.h">
<Filter>1. Modules\ripple_net</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="wallet.xml" />

View File

@@ -15,8 +15,6 @@
#include "utils.h"
#include "Log.h"
SETUP_LOG();
// How often to enforce policies.
#define POLICY_INTERVAL_SECONDS 5
@@ -169,7 +167,7 @@ void ConnectionPool::policyLowWater()
if (getPeerCount() > theConfig.PEER_CONNECT_LOW_WATER)
{
// Above low water mark, don't need more connections.
cLog(lsTRACE) << "Pool: Low water: sufficient connections: " << mConnectedMap.size() << "/" << theConfig.PEER_CONNECT_LOW_WATER;
WriteLog (lsTRACE, ConnectionPool) << "Pool: Low water: sufficient connections: " << mConnectedMap.size() << "/" << theConfig.PEER_CONNECT_LOW_WATER;
nothing();
}
@@ -183,7 +181,7 @@ void ConnectionPool::policyLowWater()
else if (!peerAvailable(strIp, iPort))
{
// No more connections available to start.
cLog(lsTRACE) << "Pool: Low water: no peers available.";
WriteLog (lsTRACE, ConnectionPool) << "Pool: Low water: no peers available.";
// XXX Might ask peers for more ips.
nothing();
@@ -191,11 +189,11 @@ void ConnectionPool::policyLowWater()
else
{
// Try to start connection.
cLog(lsTRACE) << "Pool: Low water: start connection.";
WriteLog (lsTRACE, ConnectionPool) << "Pool: Low water: start connection.";
if (!peerConnect(strIp, iPort))
{
cLog(lsINFO) << "Pool: Low water: already connected.";
WriteLog (lsINFO, ConnectionPool) << "Pool: Low water: already connected.";
}
// Check if we need more.
@@ -213,7 +211,7 @@ void ConnectionPool::policyEnforce()
if (((++mPhase) % 12) == 0)
{
cLog(lsTRACE) << "Making configured connections";
WriteLog (lsTRACE, ConnectionPool) << "Making configured connections";
makeConfigured();
}
@@ -321,11 +319,11 @@ Peer::pointer ConnectionPool::peerConnect(const std::string& strIp, int iPort)
if (ppResult)
{
ppResult->connect(strIp, iPort);
cLog(lsDEBUG) << "Pool: Connecting: " << strIp << " " << iPort;
WriteLog (lsDEBUG, ConnectionPool) << "Pool: Connecting: " << strIp << " " << iPort;
}
else
{
cLog(lsTRACE) << "Pool: Already connected: " << strIp << " " << iPort;
WriteLog (lsTRACE, ConnectionPool) << "Pool: Already connected: " << strIp << " " << iPort;
}
return ppResult;
@@ -386,7 +384,7 @@ bool ConnectionPool::peerConnected(Peer::ref peer, const RippleAddress& naPeer,
if (naPeer == theApp->getWallet().getNodePublic())
{
cLog(lsINFO) << "Pool: Connected: self: " << ADDRESS_SHARED(peer) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
WriteLog (lsINFO, ConnectionPool) << "Pool: Connected: self: " << ADDRESS_SHARED(peer) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
}
else
{
@@ -396,7 +394,7 @@ bool ConnectionPool::peerConnected(Peer::ref peer, const RippleAddress& naPeer,
if (itCm == mConnectedMap.end())
{
// New connection.
//cLog(lsINFO) << "Pool: Connected: new: " << ADDRESS_SHARED(peer) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Connected: new: " << ADDRESS_SHARED(peer) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
mConnectedMap[naPeer] = peer;
bNew = true;
@@ -412,7 +410,7 @@ bool ConnectionPool::peerConnected(Peer::ref peer, const RippleAddress& naPeer,
if (itCm->second->getIP().empty())
{
// Old peer did not know it's IP.
//cLog(lsINFO) << "Pool: Connected: redundant: outbound: " << ADDRESS_SHARED(peer) << " discovered: " << ADDRESS_SHARED(itCm->second) << ": " << strIP << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Connected: redundant: outbound: " << ADDRESS_SHARED(peer) << " discovered: " << ADDRESS_SHARED(itCm->second) << ": " << strIP << " " << iPort;
itCm->second->setIpPort(strIP, iPort);
@@ -422,14 +420,14 @@ bool ConnectionPool::peerConnected(Peer::ref peer, const RippleAddress& naPeer,
else
{
// Old peer knew its IP. Do nothing.
//cLog(lsINFO) << "Pool: Connected: redundant: outbound: rediscovered: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Connected: redundant: outbound: rediscovered: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
nothing();
}
}
else
{
//cLog(lsINFO) << "Pool: Connected: redundant: inbound: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Connected: redundant: inbound: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
nothing();
}
@@ -450,12 +448,12 @@ void ConnectionPool::peerDisconnected(Peer::ref peer, const RippleAddress& naPee
if (itCm == mConnectedMap.end())
{
// Did not find it. Not already connecting or connected.
cLog(lsWARNING) << "Pool: disconnected: Internal Error: mConnectedMap was inconsistent.";
WriteLog (lsWARNING, ConnectionPool) << "Pool: disconnected: Internal Error: mConnectedMap was inconsistent.";
// XXX Maybe bad error, considering we have racing connections, may not so bad.
}
else if (itCm->second != peer)
{
cLog(lsWARNING) << "Pool: disconected: non canonical entry";
WriteLog (lsWARNING, ConnectionPool) << "Pool: disconected: non canonical entry";
nothing();
}
@@ -464,12 +462,12 @@ void ConnectionPool::peerDisconnected(Peer::ref peer, const RippleAddress& naPee
// Found it. Delete it.
mConnectedMap.erase(itCm);
//cLog(lsINFO) << "Pool: disconnected: " << naPeer.humanNodePublic() << " " << peer->getIP() << " " << peer->getPort();
//WriteLog (lsINFO, ConnectionPool) << "Pool: disconnected: " << naPeer.humanNodePublic() << " " << peer->getIP() << " " << peer->getPort();
}
}
else
{
//cLog(lsINFO) << "Pool: disconnected: anonymous: " << peer->getIP() << " " << peer->getPort();
//WriteLog (lsINFO, ConnectionPool) << "Pool: disconnected: anonymous: " << peer->getIP() << " " << peer->getPort();
}
assert(peer->getPeerId() != 0);
@@ -498,7 +496,7 @@ bool ConnectionPool::peerScanSet(const std::string& strIp, int iPort)
boost::posix_time::ptime tpNow = boost::posix_time::second_clock::universal_time();
boost::posix_time::ptime tpNext = tpNow + boost::posix_time::seconds(iInterval);
//cLog(lsINFO) << str(boost::format("Pool: Scan: schedule create: %s %s (next %s, delay=%d)")
//WriteLog (lsINFO, ConnectionPool) << str(boost::format("Pool: Scan: schedule create: %s %s (next %s, delay=%d)")
// % mScanIp % mScanPort % tpNext % (tpNext-tpNow).total_seconds());
db->executeSQL(str(boost::format("UPDATE PeerIps SET ScanNext=%d,ScanInterval=%d WHERE IpPort=%s;")
@@ -514,14 +512,14 @@ bool ConnectionPool::peerScanSet(const std::string& strIp, int iPort)
// boost::posix_time::ptime tpNow = boost::posix_time::second_clock::universal_time();
// boost::posix_time::ptime tpNext = ptFromSeconds(db->getInt("ScanNext"));
//cLog(lsINFO) << str(boost::format("Pool: Scan: schedule exists: %s %s (next %s, delay=%d)")
//WriteLog (lsINFO, ConnectionPool) << str(boost::format("Pool: Scan: schedule exists: %s %s (next %s, delay=%d)")
// % mScanIp % mScanPort % tpNext % (tpNext-tpNow).total_seconds());
}
db->endIterRows();
}
else
{
//cLog(lsWARNING) << "Pool: Scan: peer wasn't in PeerIps: " << strIp << " " << iPort;
//WriteLog (lsWARNING, ConnectionPool) << "Pool: Scan: peer wasn't in PeerIps: " << strIp << " " << iPort;
}
return bScanDirty;
@@ -536,7 +534,7 @@ void ConnectionPool::peerClosed(Peer::ref peer, const std::string& strIp, int iP
// If the connection was our scan, we are no longer scanning.
if (mScanning && mScanning == peer)
{
//cLog(lsINFO) << "Pool: Scan: scan fail: " << strIp << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Scan: scan fail: " << strIp << " " << iPort;
mScanning.reset(); // No longer scanning.
bScanRefresh = true; // Look for more to scan.
@@ -551,13 +549,13 @@ void ConnectionPool::peerClosed(Peer::ref peer, const std::string& strIp, int iP
if (itIp == mIpMap.end())
{
// Did not find it. Not already connecting or connected.
cLog(lsWARNING) << "Pool: Closed: UNEXPECTED: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
WriteLog (lsWARNING, ConnectionPool) << "Pool: Closed: UNEXPECTED: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
// XXX Internal error.
}
else if (mIpMap[ipPeer] == peer)
{
// We were the identified connection.
//cLog(lsINFO) << "Pool: Closed: identified: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Closed: identified: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
// Delete our entry.
mIpMap.erase(itIp);
@@ -567,7 +565,7 @@ void ConnectionPool::peerClosed(Peer::ref peer, const std::string& strIp, int iP
else
{
// Found it. But, we were redundant.
//cLog(lsINFO) << "Pool: Closed: redundant: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
//WriteLog (lsINFO, ConnectionPool) << "Pool: Closed: redundant: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
}
}
@@ -591,7 +589,7 @@ void ConnectionPool::peerVerified(Peer::ref peer)
std::string strIpPort = str(boost::format("%s %d") % strIp % iPort);
//cLog(lsINFO) << str(boost::format("Pool: Scan: connected: %s %s %s (scanned)") % ADDRESS_SHARED(peer) % strIp % iPort);
//WriteLog (lsINFO, ConnectionPool) << str(boost::format("Pool: Scan: connected: %s %s %s (scanned)") % ADDRESS_SHARED(peer) % strIp % iPort);
if (peer->getNodePublic() == theApp->getWallet().getNodePublic())
{
@@ -656,7 +654,7 @@ void ConnectionPool::scanRefresh()
else if (mScanning)
{
// Currently scanning, will scan again after completion.
cLog(lsTRACE) << "Pool: Scan: already scanning";
WriteLog (lsTRACE, ConnectionPool) << "Pool: Scan: already scanning";
nothing();
}
@@ -694,7 +692,7 @@ void ConnectionPool::scanRefresh()
if (tpNow.is_not_a_date_time())
{
//cLog(lsINFO) << "Pool: Scan: stop.";
//WriteLog (lsINFO, ConnectionPool) << "Pool: Scan: stop.";
(void) mScanTimer.cancel();
}
@@ -709,7 +707,7 @@ void ConnectionPool::scanRefresh()
tpNext = tpNow + boost::posix_time::seconds(iInterval);
//cLog(lsINFO) << str(boost::format("Pool: Scan: Now: %s %s (next %s, delay=%d)")
//WriteLog (lsINFO, ConnectionPool) << str(boost::format("Pool: Scan: Now: %s %s (next %s, delay=%d)")
// % mScanIp % mScanPort % tpNext % (tpNext-tpNow).total_seconds());
iInterval *= 2;
@@ -734,7 +732,7 @@ void ConnectionPool::scanRefresh()
}
else
{
//cLog(lsINFO) << str(boost::format("Pool: Scan: Next: %s (next %s, delay=%d)")
//WriteLog (lsINFO, ConnectionPool) << str(boost::format("Pool: Scan: Next: %s (next %s, delay=%d)")
// % strIpPort % tpNext % (tpNext-tpNow).total_seconds());
mScanTimer.expires_at(tpNext);

View File

@@ -24,7 +24,6 @@
// code assumes this node is synched (and will continue to do so until
// there's a functional network.
SETUP_LOG();
DECLARE_INSTANCE(InfoSub);
void InfoSub::onSendEmpty()
@@ -99,7 +98,7 @@ void NetworkOPs::closeTimeOffset(int offset)
mCloseTimeOffset += (offset - 3) / 4;
else
mCloseTimeOffset = (mCloseTimeOffset * 3) / 4;
tLog(mCloseTimeOffset != 0, lsINFO) << "Close time offset now " << mCloseTimeOffset;
CondLog (mCloseTimeOffset != 0, lsINFO, NetworkOPs) << "Close time offset now " << mCloseTimeOffset;
}
uint32 NetworkOPs::getLedgerID(const uint256& hash)
@@ -121,7 +120,7 @@ Ledger::pointer NetworkOPs::getLedgerBySeq(const uint32 seq)
return ret;
// We should have this ledger but we don't
cLog(lsWARNING) << "We should have ledger " << seq;
WriteLog (lsWARNING, NetworkOPs) << "We should have ledger " << seq;
return ret;
}
@@ -171,13 +170,13 @@ void NetworkOPs::submitTransaction(Job&, SerializedTransaction::pointer iTrans,
int flags;
if (theApp->isNew(suppress, 0, flags) && ((flags & SF_RETRY) != 0))
{
cLog(lsWARNING) << "Redundant transactions submitted";
WriteLog (lsWARNING, NetworkOPs) << "Redundant transactions submitted";
return;
}
if ((flags & SF_BAD) != 0)
{
cLog(lsWARNING) << "Submitted transaction cached bad";
WriteLog (lsWARNING, NetworkOPs) << "Submitted transaction cached bad";
return;
}
@@ -187,7 +186,7 @@ void NetworkOPs::submitTransaction(Job&, SerializedTransaction::pointer iTrans,
{
if (!trans->checkSign())
{
cLog(lsWARNING) << "Submitted transaction has bad signature";
WriteLog (lsWARNING, NetworkOPs) << "Submitted transaction has bad signature";
theApp->isNewFlag(suppress, SF_BAD);
return;
}
@@ -195,7 +194,7 @@ void NetworkOPs::submitTransaction(Job&, SerializedTransaction::pointer iTrans,
}
catch (...)
{
cLog(lsWARNING) << "Exception checking transaction " << suppress;
WriteLog (lsWARNING, NetworkOPs) << "Exception checking transaction " << suppress;
return;
}
}
@@ -226,9 +225,9 @@ Transaction::pointer NetworkOPs::submitTransactionSync(Transaction::ref tpTrans,
}
else
{
cLog(lsFATAL) << "Transaction reconstruction failure";
cLog(lsFATAL) << tpTransNew->getSTransaction()->getJson(0);
cLog(lsFATAL) << tpTrans->getSTransaction()->getJson(0);
WriteLog (lsFATAL, NetworkOPs) << "Transaction reconstruction failure";
WriteLog (lsFATAL, NetworkOPs) << tpTransNew->getSTransaction()->getJson(0);
WriteLog (lsFATAL, NetworkOPs) << tpTrans->getSTransaction()->getJson(0);
assert(false);
@@ -269,25 +268,25 @@ void NetworkOPs::runTransactionQueue()
if (isTerRetry(r))
{ // transaction should be held
cLog(lsDEBUG) << "Transaction should be held: " << r;
WriteLog (lsDEBUG, NetworkOPs) << "Transaction should be held: " << r;
dbtx->setStatus(HELD);
theApp->getMasterTransaction().canonicalize(dbtx, true);
mLedgerMaster->addHeldTransaction(dbtx);
}
else if (r == tefPAST_SEQ)
{ // duplicate or conflict
cLog(lsINFO) << "Transaction is obsolete";
WriteLog (lsINFO, NetworkOPs) << "Transaction is obsolete";
dbtx->setStatus(OBSOLETE);
}
else if (r == tesSUCCESS)
{
cLog(lsINFO) << "Transaction is now included in open ledger";
WriteLog (lsINFO, NetworkOPs) << "Transaction is now included in open ledger";
dbtx->setStatus(INCLUDED);
theApp->getMasterTransaction().canonicalize(dbtx, true);
}
else
{
cLog(lsDEBUG) << "Status other than success " << r;
WriteLog (lsDEBUG, NetworkOPs) << "Status other than success " << r;
dbtx->setStatus(INVALID);
}
@@ -332,7 +331,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
{ // signature not checked
if (!trans->checkSign())
{
cLog(lsINFO) << "Transaction has bad signature";
WriteLog (lsINFO, NetworkOPs) << "Transaction has bad signature";
trans->setStatus(INVALID);
trans->setResult(temBAD_SIGNATURE);
theApp->isNewFlag(trans->getID(), SF_BAD);
@@ -357,7 +356,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
if (r != tesSUCCESS)
{
std::string token, human;
tLog(transResultInfo(r, token, human), lsINFO) << "TransactionResult: " << token << ": " << human;
CondLog (transResultInfo(r, token, human), lsINFO, NetworkOPs) << "TransactionResult: " << token << ": " << human;
}
#endif
@@ -369,25 +368,25 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
if (r == tesSUCCESS)
{
cLog(lsINFO) << "Transaction is now included in open ledger";
WriteLog (lsINFO, NetworkOPs) << "Transaction is now included in open ledger";
trans->setStatus(INCLUDED);
theApp->getMasterTransaction().canonicalize(trans, true);
}
else if (r == tefPAST_SEQ)
{ // duplicate or conflict
cLog(lsINFO) << "Transaction is obsolete";
WriteLog (lsINFO, NetworkOPs) << "Transaction is obsolete";
trans->setStatus(OBSOLETE);
}
else if (isTerRetry(r))
{ // transaction should be held
cLog(lsDEBUG) << "Transaction should be held: " << r;
WriteLog (lsDEBUG, NetworkOPs) << "Transaction should be held: " << r;
trans->setStatus(HELD);
theApp->getMasterTransaction().canonicalize(trans, true);
mLedgerMaster->addHeldTransaction(trans);
}
else
{
cLog(lsDEBUG) << "Status other than success " << r;
WriteLog (lsDEBUG, NetworkOPs) << "Status other than success " << r;
trans->setStatus(INVALID);
}
@@ -455,21 +454,21 @@ STVector256 NetworkOPs::getDirNodeInfo(
if (sleNode)
{
cLog(lsDEBUG) << "getDirNodeInfo: node index: " << uNodeIndex.ToString();
WriteLog (lsDEBUG, NetworkOPs) << "getDirNodeInfo: node index: " << uNodeIndex.ToString();
cLog(lsTRACE) << "getDirNodeInfo: first: " << strHex(sleNode->getFieldU64(sfIndexPrevious));
cLog(lsTRACE) << "getDirNodeInfo: last: " << strHex(sleNode->getFieldU64(sfIndexNext));
WriteLog (lsTRACE, NetworkOPs) << "getDirNodeInfo: first: " << strHex(sleNode->getFieldU64(sfIndexPrevious));
WriteLog (lsTRACE, NetworkOPs) << "getDirNodeInfo: last: " << strHex(sleNode->getFieldU64(sfIndexNext));
uNodePrevious = sleNode->getFieldU64(sfIndexPrevious);
uNodeNext = sleNode->getFieldU64(sfIndexNext);
svIndexes = sleNode->getFieldV256(sfIndexes);
cLog(lsTRACE) << "getDirNodeInfo: first: " << strHex(uNodePrevious);
cLog(lsTRACE) << "getDirNodeInfo: last: " << strHex(uNodeNext);
WriteLog (lsTRACE, NetworkOPs) << "getDirNodeInfo: first: " << strHex(uNodePrevious);
WriteLog (lsTRACE, NetworkOPs) << "getDirNodeInfo: last: " << strHex(uNodeNext);
}
else
{
cLog(lsINFO) << "getDirNodeInfo: node index: NOT FOUND: " << uNodeIndex.ToString();
WriteLog (lsINFO, NetworkOPs) << "getDirNodeInfo: node index: NOT FOUND: " << uNodeIndex.ToString();
uNodePrevious = 0;
uNodeNext = 0;
@@ -588,7 +587,7 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
if ((result == boost::asio::error::operation_aborted) || theConfig.RUN_STANDALONE)
{
cLog(lsFATAL) << "Network state timer error: " << result;
WriteLog (lsFATAL, NetworkOPs) << "Network state timer error: " << result;
return;
}
@@ -605,7 +604,7 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
if (mMode != omDISCONNECTED)
{
setMode(omDISCONNECTED);
cLog(lsWARNING) << "Node count (" << peerList.size() <<
WriteLog (lsWARNING, NetworkOPs) << "Node count (" << peerList.size() <<
") has fallen below quorum (" << theConfig.NETWORK_QUORUM << ").";
}
return;
@@ -613,7 +612,7 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
if (mMode == omDISCONNECTED)
{
setMode(omCONNECTED);
cLog(lsINFO) << "Node count (" << peerList.size() << ") is sufficient.";
WriteLog (lsINFO, NetworkOPs) << "Node count (" << peerList.size() << ") is sufficient.";
}
// Check if the last validated ledger forces a change between these states
@@ -671,7 +670,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
// agree? And do we have no better ledger available?
// If so, we are either tracking or full.
cLog(lsTRACE) << "NetworkOPs::checkLastClosedLedger";
WriteLog (lsTRACE, NetworkOPs) << "NetworkOPs::checkLastClosedLedger";
Ledger::pointer ourClosed = mLedgerMaster->getClosedLedger();
if (!ourClosed)
@@ -679,8 +678,8 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
uint256 closedLedger = ourClosed->getHash();
uint256 prevClosedLedger = ourClosed->getParentHash();
cLog(lsTRACE) << "OurClosed: " << closedLedger;
cLog(lsTRACE) << "PrevClosed: " << prevClosedLedger;
WriteLog (lsTRACE, NetworkOPs) << "OurClosed: " << closedLedger;
WriteLog (lsTRACE, NetworkOPs) << "PrevClosed: " << prevClosedLedger;
boost::unordered_map<uint256, ValidationCount> ledgers;
{
@@ -728,14 +727,14 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
for (boost::unordered_map<uint256, ValidationCount>::iterator it = ledgers.begin(), end = ledgers.end();
it != end; ++it)
{
cLog(lsDEBUG) << "L: " << it->first << " t=" << it->second.trustedValidations <<
WriteLog (lsDEBUG, NetworkOPs) << "L: " << it->first << " t=" << it->second.trustedValidations <<
", n=" << it->second.nodesUsing;
// Temporary logging to make sure tiebreaking isn't broken
if (it->second.trustedValidations > 0)
cLog(lsTRACE) << " TieBreakTV: " << it->second.highValidation;
WriteLog (lsTRACE, NetworkOPs) << " TieBreakTV: " << it->second.highValidation;
else
tLog(it->second.nodesUsing > 0, lsTRACE) << " TieBreakNU: " << it->second.highNodeUsing;
CondLog (it->second.nodesUsing > 0, lsTRACE, NetworkOPs) << " TieBreakNU: " << it->second.highNodeUsing;
if (it->second > bestVC)
{
@@ -747,7 +746,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
if (switchLedgers && (closedLedger == prevClosedLedger))
{ // don't switch to our own previous ledger
cLog(lsINFO) << "We won't switch to our own previous ledger";
WriteLog (lsINFO, NetworkOPs) << "We won't switch to our own previous ledger";
networkClosed = ourClosed->getHash();
switchLedgers = false;
}
@@ -765,22 +764,22 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
return false;
}
cLog(lsWARNING) << "We are not running on the consensus ledger";
cLog(lsINFO) << "Our LCL: " << ourClosed->getJson(0);
cLog(lsINFO) << "Net LCL " << closedLedger;
WriteLog (lsWARNING, NetworkOPs) << "We are not running on the consensus ledger";
WriteLog (lsINFO, NetworkOPs) << "Our LCL: " << ourClosed->getJson(0);
WriteLog (lsINFO, NetworkOPs) << "Net LCL " << closedLedger;
if ((mMode == omTRACKING) || (mMode == omFULL))
setMode(omCONNECTED);
Ledger::pointer consensus = mLedgerMaster->getLedgerByHash(closedLedger);
if (!consensus)
{
cLog(lsINFO) << "Acquiring consensus ledger " << closedLedger;
WriteLog (lsINFO, NetworkOPs) << "Acquiring consensus ledger " << closedLedger;
if (!mAcquiringLedger || (mAcquiringLedger->getHash() != closedLedger))
mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(closedLedger, 0);
if (!mAcquiringLedger || mAcquiringLedger->isFailed())
{
theApp->getMasterLedgerAcquire().dropLedger(closedLedger);
cLog(lsERROR) << "Network ledger cannot be acquired";
WriteLog (lsERROR, NetworkOPs) << "Network ledger cannot be acquired";
return true;
}
if (!mAcquiringLedger->isComplete())
@@ -800,9 +799,9 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
{ // set the newledger as our last closed ledger -- this is abnormal code
if (duringConsensus)
cLog(lsERROR) << "JUMPdc last closed ledger to " << newLedger->getHash();
WriteLog (lsERROR, NetworkOPs) << "JUMPdc last closed ledger to " << newLedger->getHash();
else
cLog(lsERROR) << "JUMP last closed ledger to " << newLedger->getHash();
WriteLog (lsERROR, NetworkOPs) << "JUMP last closed ledger to " << newLedger->getHash();
clearNeedNetworkLedger();
newLedger->setClosed();
@@ -823,15 +822,15 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger)
{
cLog(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq();
cLog(lsINFO) << " LCL is " << closingLedger->getParentHash();
WriteLog (lsINFO, NetworkOPs) << "Consensus time for ledger " << closingLedger->getLedgerSeq();
WriteLog (lsINFO, NetworkOPs) << " LCL is " << closingLedger->getParentHash();
Ledger::pointer prevLedger = mLedgerMaster->getLedgerByHash(closingLedger->getParentHash());
if (!prevLedger)
{ // this shouldn't happen unless we jump ledgers
if (mMode == omFULL)
{
cLog(lsWARNING) << "Don't have LCL, going to tracking";
WriteLog (lsWARNING, NetworkOPs) << "Don't have LCL, going to tracking";
setMode(omTRACKING);
}
return 3;
@@ -845,7 +844,7 @@ int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer clo
mConsensus = boost::make_shared<LedgerConsensus>(
networkClosed, prevLedger, mLedgerMaster->getCurrentLedger()->getCloseTimeNC());
cLog(lsDEBUG) << "Initiating consensus engine";
WriteLog (lsDEBUG, NetworkOPs) << "Initiating consensus engine";
return mConsensus->startup();
}
@@ -865,7 +864,7 @@ bool NetworkOPs::haveConsensusObject()
bool ledgerChange = checkLastClosedLedger(peerList, networkClosed);
if (!ledgerChange)
{
cLog(lsINFO) << "Beginning consensus due to peer action";
WriteLog (lsINFO, NetworkOPs) << "Beginning consensus due to peer action";
beginConsensus(networkClosed, mLedgerMaster->getCurrentLedger());
}
}
@@ -888,7 +887,7 @@ void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
if (!haveConsensusObject())
{
cLog(lsINFO) << "Received proposal outside consensus window";
WriteLog (lsINFO, NetworkOPs) << "Received proposal outside consensus window";
if (mMode == omFULL)
relay = false;
}
@@ -900,7 +899,7 @@ void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
if (!set->has_previousledger() && (checkLedger != consensusLCL))
{
cLog(lsWARNING) << "Have to re-check proposal signature due to consensus view change";
WriteLog (lsWARNING, NetworkOPs) << "Have to re-check proposal signature due to consensus view change";
assert(proposal->hasSignature());
proposal->setPrevLedger(consensusLCL);
if (proposal->checkSign())
@@ -910,7 +909,7 @@ void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
if (sigGood && (consensusLCL == proposal->getPrevLedger()))
{
relay = mConsensus->peerPosition(proposal);
cLog(lsTRACE) << "Proposal processing finished, relay=" << relay;
WriteLog (lsTRACE, NetworkOPs) << "Proposal processing finished, relay=" << relay;
}
}
@@ -922,7 +921,7 @@ void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
theApp->getConnectionPool().relayMessageBut(peers, message);
}
else
cLog(lsINFO) << "Not relaying trusted proposal";
WriteLog (lsINFO, NetworkOPs) << "Not relaying trusted proposal";
}
SHAMap::pointer NetworkOPs::getTXMap(const uint256& hash)
@@ -958,7 +957,7 @@ SMAddNode NetworkOPs::gotTXData(const boost::shared_ptr<Peer>& peer, const uint2
{
if (!haveConsensusObject())
{
cLog(lsWARNING) << "Got TX data with no consensus object";
WriteLog (lsWARNING, NetworkOPs) << "Got TX data with no consensus object";
return SMAddNode();
}
return mConsensus->peerGaveNodes(peer, hash, nodeIDs, nodeData);
@@ -968,7 +967,7 @@ bool NetworkOPs::hasTXSet(const boost::shared_ptr<Peer>& peer, const uint256& se
{
if (!haveConsensusObject())
{
cLog(lsINFO) << "Peer has TX set, not during consensus";
WriteLog (lsINFO, NetworkOPs) << "Peer has TX set, not during consensus";
return false;
}
return mConsensus->peerHasSet(peer, set, status);
@@ -994,7 +993,7 @@ void NetworkOPs::endConsensus(bool correctLCL)
BOOST_FOREACH(Peer::ref it, peerList)
if (it && (it->getClosedLedgerHash() == deadLedger))
{
cLog(lsTRACE) << "Killing obsolete peer status";
WriteLog (lsTRACE, NetworkOPs) << "Killing obsolete peer status";
it->cycleStatus();
}
mConsensus = boost::shared_ptr<LedgerConsensus>();
@@ -1104,7 +1103,7 @@ std::string
% boost::lexical_cast<std::string>(offset)
% boost::lexical_cast<std::string>(numberOfResults)
);
cLog(lsTRACE) << "txSQL query: " << sql;
WriteLog (lsTRACE, NetworkOPs) << "txSQL query: " << sql;
return sql;
}
@@ -1228,7 +1227,7 @@ std::vector<RippleAddress>
bool NetworkOPs::recvValidation(SerializedValidation::ref val, const std::string& source)
{
cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash() << " from " << source;
WriteLog (lsDEBUG, NetworkOPs) << "recvValidation " << val->getLedgerHash() << " from " << source;
return theApp->getValidations().addValidation(val, source);
}
@@ -1382,7 +1381,7 @@ void NetworkOPs::pubProposedTransaction(Ledger::ref lpCurrent, SerializedTransac
}
}
ALTransaction alt(stTxn, terResult);
cLog(lsTRACE) << "pubProposed: " << alt.getJson();
WriteLog (lsTRACE, NetworkOPs) << "pubProposed: " << alt.getJson();
pubAccountTransaction(lpCurrent, ALTransaction(stTxn, terResult), false);
}
@@ -1436,7 +1435,7 @@ void NetworkOPs::pubLedger(Ledger::ref accepted)
{
BOOST_FOREACH(const AcceptedLedger::value_type& vt, alpAccepted->getMap())
{
cLog(lsTRACE) << "pubAccepted: " << vt.second->getJson();
WriteLog (lsTRACE, NetworkOPs) << "pubAccepted: " << vt.second->getJson();
pubValidatedTransaction(lpAccepted, *vt.second);
}
}
@@ -1577,7 +1576,7 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const ALTransactio
}
}
}
cLog(lsINFO) << boost::str(boost::format("pubAccountTransaction: iProposed=%d iAccepted=%d") % iProposed % iAccepted);
WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("pubAccountTransaction: iProposed=%d iAccepted=%d") % iProposed % iAccepted);
if (!notify.empty())
{
@@ -1604,7 +1603,7 @@ void NetworkOPs::subAccount(InfoSub::ref isrListener, const boost::unordered_set
// For the connection, monitor each account.
BOOST_FOREACH(const RippleAddress& naAccountID, vnaAccountIDs)
{
cLog(lsTRACE) << boost::str(boost::format("subAccount: account: %d") % naAccountID.humanAccountID());
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("subAccount: account: %d") % naAccountID.humanAccountID());
isrListener->insertSubAccountInfo(naAccountID, uLedgerIndex);
}
@@ -1845,11 +1844,11 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
const uint256 uBookEnd = Ledger::getQualityNext(uBookBase);
uint256 uTipIndex = uBookBase;
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTakerPaysCurrencyID=%s uTakerPaysIssuerID=%s") % STAmount::createHumanCurrency(uTakerPaysCurrencyID) % RippleAddress::createHumanAccountID(uTakerPaysIssuerID));
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTakerGetsCurrencyID=%s uTakerGetsIssuerID=%s") % STAmount::createHumanCurrency(uTakerGetsCurrencyID) % RippleAddress::createHumanAccountID(uTakerGetsIssuerID));
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uBookBase=%s") % uBookBase);
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uBookEnd=%s") % uBookEnd);
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uTakerPaysCurrencyID=%s uTakerPaysIssuerID=%s") % STAmount::createHumanCurrency(uTakerPaysCurrencyID) % RippleAddress::createHumanAccountID(uTakerPaysIssuerID));
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uTakerGetsCurrencyID=%s uTakerGetsIssuerID=%s") % STAmount::createHumanCurrency(uTakerGetsCurrencyID) % RippleAddress::createHumanAccountID(uTakerGetsIssuerID));
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uBookBase=%s") % uBookBase);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uBookEnd=%s") % uBookEnd);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
LedgerEntrySet lesActive(lpLedger, tapNONE, true);
@@ -1871,12 +1870,12 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
if (bDirectAdvance) {
bDirectAdvance = false;
cLog(lsTRACE) << "getBookPage: bDirectAdvance";
WriteLog (lsTRACE, NetworkOPs) << "getBookPage: bDirectAdvance";
sleOfferDir = lesActive.entryCache(ltDIR_NODE, lpLedger->getNextLedgerIndex(uTipIndex, uBookEnd));
if (!sleOfferDir)
{
cLog(lsTRACE) << "getBookPage: bDone";
WriteLog (lsTRACE, NetworkOPs) << "getBookPage: bDone";
bDone = true;
}
else
@@ -1887,8 +1886,8 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
lesActive.dirFirst(uTipIndex, sleBookNode, uBookEntry, uOfferIndex);
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uOfferIndex=%s") % uOfferIndex);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uOfferIndex=%s") % uOfferIndex);
}
}
@@ -1914,14 +1913,14 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
// Found in running balance table.
saOwnerFunds = umBalanceEntry->second;
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saOwnerFunds=%s (cached)") % saOwnerFunds.getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saOwnerFunds=%s (cached)") % saOwnerFunds.getFullText());
}
else
{
// Did not find balance in table.
saOwnerFunds = lesActive.accountHolds(uOfferOwnerID, uTakerGetsCurrencyID, uTakerGetsIssuerID);
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saOwnerFunds=%s (new)") % saOwnerFunds.getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saOwnerFunds=%s (new)") % saOwnerFunds.getFullText());
if (saOwnerFunds.isNegative())
{
// Treat negative funds as zero.
@@ -1958,12 +1957,12 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
}
else
{
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saTakerGets=%s") % saTakerGets.getFullText());
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saTakerPays=%s") % saTakerPays.getFullText());
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saOwnerFunds=%s") % saOwnerFunds.getFullText());
// cLog(lsINFO) << boost::str(boost::format("getBookPage: saDirRate=%s") % saDirRate.getText());
// cLog(lsINFO) << boost::str(boost::format("getBookPage: multiply=%s") % STAmount::multiply(saTakerGetsFunded, saDirRate).getFullText());
// cLog(lsINFO) << boost::str(boost::format("getBookPage: multiply=%s") % STAmount::multiply(saTakerGetsFunded, saDirRate, saTakerPays).getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saTakerGets=%s") % saTakerGets.getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saTakerPays=%s") % saTakerPays.getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saOwnerFunds=%s") % saOwnerFunds.getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: saDirRate=%s") % saDirRate.getText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: multiply=%s") % STAmount::multiply(saTakerGetsFunded, saDirRate).getFullText());
// WriteLog (lsINFO, NetworkOPs) << boost::str(boost::format("getBookPage: multiply=%s") % STAmount::multiply(saTakerGetsFunded, saDirRate, saTakerPays).getFullText());
// Only provide, if not fully funded.
@@ -1993,7 +1992,7 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
}
else
{
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uOfferIndex=%s") % uOfferIndex);
WriteLog (lsTRACE, NetworkOPs) << boost::str(boost::format("getBookPage: uOfferIndex=%s") % uOfferIndex);
}
}
}
@@ -2008,12 +2007,12 @@ void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer,
{
if (upTime() > (uUptime + 1))
{
cLog(lsINFO) << "Fetch pack request got stale";
WriteLog (lsINFO, NetworkOPs) << "Fetch pack request got stale";
return;
}
if (theApp->getFeeTrack().isLoaded())
{
cLog(lsINFO) << "Too busy to make fetch pack";
WriteLog (lsINFO, NetworkOPs) << "Too busy to make fetch pack";
return;
}
@@ -2069,13 +2068,13 @@ void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer,
wantLedger = getLedgerByHash(haveLedger->getParentHash());
} while (wantLedger && (upTime() <= (uUptime + 1)));
cLog(lsINFO) << "Built fetch pack with " << reply.objects().size() << " nodes";
WriteLog (lsINFO, NetworkOPs) << "Built fetch pack with " << reply.objects().size() << " nodes";
PackedMessage::pointer msg = boost::make_shared<PackedMessage>(reply, ripple::mtGET_OBJECTS);
peer->sendPacket(msg, false);
}
catch (...)
{
cLog(lsWARNING) << "Exception building fetch pach";
WriteLog (lsWARNING, NetworkOPs) << "Exception building fetch pach";
}
}
@@ -2097,7 +2096,7 @@ bool NetworkOPs::getFetchPack(const uint256& hash, std::vector<unsigned char>& d
mFetchPack.del(hash, false);
if (hash != Serializer::getSHA512Half(data))
{
cLog(lsWARNING) << "Bad entry in fetch pack";
WriteLog (lsWARNING, NetworkOPs) << "Bad entry in fetch pack";
return false;
}
return true;
@@ -2136,7 +2135,7 @@ void NetworkOPs::gotFetchPack(bool progress, uint32 seq)
void NetworkOPs::missingNodeInLedger(uint32 seq)
{
cLog(lsWARNING) << "We are missing a node in ledger " << seq;
WriteLog (lsWARNING, NetworkOPs) << "We are missing a node in ledger " << seq;
uint256 hash = theApp->getLedgerMaster().getHashBySeq(seq);
if (hash.isNonZero())
theApp->getMasterLedgerAcquire().findCreate(hash, seq);

View File

@@ -15,7 +15,6 @@
#include "utils.h"
#include "Log.h"
SETUP_LOG();
DECLARE_INSTANCE(Peer);
// Don't try to run past receiving nonsense from a peer
@@ -42,7 +41,7 @@ Peer::Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx,
mActivityTimer(io_service),
mIOStrand(io_service)
{
cLog(lsDEBUG) << "CREATING PEER: " << ADDRESS(this);
WriteLog (lsDEBUG, Peer) << "CREATING PEER: " << ADDRESS(this);
}
void Peer::handleWrite(const boost::system::error_code& error, size_t bytes_transferred)
@@ -61,7 +60,7 @@ void Peer::handleWrite(const boost::system::error_code& error, size_t bytes_tran
}
else if (error)
{
cLog(lsINFO) << "Peer: Write: Error: " << ADDRESS(this) << ": bytes=" << bytes_transferred << ": " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Write: Error: " << ADDRESS(this) << ": bytes=" << bytes_transferred << ": " << error.category().name() << ": " << error.message() << ": " << error;
detach("hw", true);
}
@@ -82,7 +81,7 @@ void Peer::setIpPort(const std::string& strIP, int iPort)
mIpPort = make_pair(strIP, iPort);
mLoad.rename(strIP);
cLog(lsDEBUG) << "Peer: Set: "
WriteLog (lsDEBUG, Peer) << "Peer: Set: "
<< ADDRESS(this) << "> "
<< (mNodePublic.isValid() ? mNodePublic.humanNodePublic() : "-") << " " << getIP() << " " << getPort();
}
@@ -98,9 +97,9 @@ void Peer::detach(const char *rsn, bool onIOStrand)
{
mDetaching = true; // Race is ok.
tLog(mCluster, lsWARNING) << "Cluster peer detach \"" << mNodeName << "\": " << rsn;
CondLog (mCluster, lsWARNING, Peer) << "Cluster peer detach \"" << mNodeName << "\": " << rsn;
/*
cLog(lsDEBUG) << "Peer: Detach: "
WriteLog (lsDEBUG, Peer) << "Peer: Detach: "
<< ADDRESS(this) << "> "
<< rsn << ": "
<< (mNodePublic.isValid() ? mNodePublic.humanNodePublic() : "-") << " " << getIP() << " " << getPort();
@@ -128,7 +127,7 @@ void Peer::detach(const char *rsn, bool onIOStrand)
mIpPort.first.clear(); // Be idempotent.
}
/*
cLog(lsDEBUG) << "Peer: Detach: "
WriteLog (lsDEBUG, Peer) << "Peer: Detach: "
<< ADDRESS(this) << "< "
<< rsn << ": "
<< (mNodePublic.isValid() ? mNodePublic.humanNodePublic() : "-") << " " << getIP() << " " << getPort();
@@ -174,11 +173,11 @@ void Peer::handleVerifyTimer(const boost::system::error_code& ecResult)
}
else if (ecResult)
{
cLog(lsINFO) << "Peer verify timer error";
WriteLog (lsINFO, Peer) << "Peer verify timer error";
}
else
{
//cLog(lsINFO) << "Peer: Verify: Peer failed to verify in time.";
//WriteLog (lsINFO, Peer) << "Peer: Verify: Peer failed to verify in time.";
detach("hvt", true);
}
@@ -204,7 +203,7 @@ void Peer::connect(const std::string& strIp, int iPort)
if (err || itrEndpoint == boost::asio::ip::tcp::resolver::iterator())
{
cLog(lsWARNING) << "Peer: Connect: Bad IP: " << strIp;
WriteLog (lsWARNING, Peer) << "Peer: Connect: Bad IP: " << strIp;
detach("c", false);
return;
}
@@ -216,7 +215,7 @@ void Peer::connect(const std::string& strIp, int iPort)
if (err)
{
cLog(lsWARNING) << "Peer: Connect: Failed to set timer.";
WriteLog (lsWARNING, Peer) << "Peer: Connect: Failed to set timer.";
detach("c2", false);
return;
}
@@ -224,7 +223,7 @@ void Peer::connect(const std::string& strIp, int iPort)
if (!err)
{
cLog(lsINFO) << "Peer: Connect: Outbound: " << ADDRESS(this) << ": " << mIpPort.first << " " << mIpPort.second;
WriteLog (lsINFO, Peer) << "Peer: Connect: Outbound: " << ADDRESS(this) << ": " << mIpPort.first << " " << mIpPort.second;
boost::asio::async_connect(
getSocket(),
@@ -245,7 +244,7 @@ void Peer::handleStart(const boost::system::error_code& error)
{
if (error)
{
cLog(lsINFO) << "Peer: Handshake: Error: " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Handshake: Error: " << error.category().name() << ": " << error.message() << ": " << error;
detach("hs", true);
}
else
@@ -260,12 +259,12 @@ void Peer::handleConnect(const boost::system::error_code& error, boost::asio::ip
{
if (error)
{
cLog(lsINFO) << "Peer: Connect: Error: " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Connect: Error: " << error.category().name() << ": " << error.message() << ": " << error;
detach("hc", true);
}
else
{
cLog(lsINFO) << "Connect peer: success.";
WriteLog (lsINFO, Peer) << "Connect peer: success.";
mSocketSsl.set_verify_mode(boost::asio::ssl::verify_none);
@@ -292,7 +291,7 @@ void Peer::connected(const boost::system::error_code& error)
{
// Not redundant ip and port, handshake, and start.
cLog(lsINFO) << "Peer: Inbound: Accepted: " << ADDRESS(this) << ": " << strIp << " " << iPort;
WriteLog (lsINFO, Peer) << "Peer: Inbound: Accepted: " << ADDRESS(this) << ": " << strIp << " " << iPort;
mSocketSsl.set_verify_mode(boost::asio::ssl::verify_none);
@@ -302,7 +301,7 @@ void Peer::connected(const boost::system::error_code& error)
}
else if (!mDetaching)
{
cLog(lsINFO) << "Peer: Inbound: Error: " << ADDRESS(this) << ": " << strIp << " " << iPort << " : " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Inbound: Error: " << ADDRESS(this) << ": " << strIp << " " << iPort << " : " << error.category().name() << ": " << error.message() << ": " << error;
detach("ctd", false);
}
@@ -390,12 +389,12 @@ void Peer::handleReadHeader(const boost::system::error_code& error)
{
if (mCluster)
{
cLog(lsINFO) << "Peer: Cluster connection lost to \"" << mNodeName << "\": " <<
WriteLog (lsINFO, Peer) << "Peer: Cluster connection lost to \"" << mNodeName << "\": " <<
error.category().name() << ": " << error.message() << ": " << error;
}
else
{
cLog(lsINFO) << "Peer: Header: Error: " << getIP() << ": " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Header: Error: " << getIP() << ": " << error.category().name() << ": " << error.message() << ": " << error;
}
detach("hrh2", true);
}
@@ -411,12 +410,12 @@ void Peer::handleReadBody(const boost::system::error_code& error)
{
if (mCluster)
{
cLog(lsINFO) << "Peer: Cluster connection lost to \"" << mNodeName << "\": " <<
WriteLog (lsINFO, Peer) << "Peer: Cluster connection lost to \"" << mNodeName << "\": " <<
error.category().name() << ": " << error.message() << ": " << error;
}
else
{
cLog(lsINFO) << "Peer: Body: Error: " << getIP() << ": " << error.category().name() << ": " << error.message() << ": " << error;
WriteLog (lsINFO, Peer) << "Peer: Body: Error: " << getIP() << ": " << error.category().name() << ": " << error.message() << ": " << error;
}
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
detach("hrb", true);
@@ -443,7 +442,7 @@ void Peer::processReadBuffer()
// If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent.
if (mHelloed == (type == ripple::mtHELLO))
{
cLog(lsWARNING) << "Wrong message type: " << type;
WriteLog (lsWARNING, Peer) << "Wrong message type: " << type;
detach("prb1", true);
}
else
@@ -457,7 +456,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvHello(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -468,7 +467,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvErrorMessage(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -479,7 +478,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvPing(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -490,7 +489,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetContacts(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -502,7 +501,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvContact(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -514,7 +513,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetPeers(msg, sl);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -526,7 +525,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvPeers(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -537,7 +536,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvSearchTransaction(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -548,7 +547,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetAccount(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -559,7 +558,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvAccount(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -570,7 +569,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvTransaction(msg, sl);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -581,7 +580,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvStatus(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -592,7 +591,7 @@ void Peer::processReadBuffer()
if (msg->ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvPropose(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -603,7 +602,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetLedger(msg, sl);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -614,7 +613,7 @@ void Peer::processReadBuffer()
if (msg->ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvLedger(msg, sl);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -625,7 +624,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvHaveTxSet(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -636,7 +635,7 @@ void Peer::processReadBuffer()
if (msg->ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvValidation(msg, sl);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
#if 0
@@ -646,7 +645,7 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recv(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -658,7 +657,7 @@ void Peer::processReadBuffer()
if (msg->ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvGetObjectByHash(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
@@ -669,15 +668,15 @@ void Peer::processReadBuffer()
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvProofWork(msg);
else
cLog(lsWARNING) << "parse error: " << type;
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
default:
event->reName("Peer::unknown");
cLog(lsWARNING) << "Unknown Msg: " << type;
cLog(lsWARNING) << strHex(&mReadbuf[0], mReadbuf.size());
WriteLog (lsWARNING, Peer) << "Unknown Msg: " << type;
WriteLog (lsWARNING, Peer) << strHex(&mReadbuf[0], mReadbuf.size());
}
}
}
@@ -707,14 +706,14 @@ void Peer::recvHello(ripple::TMHello& packet)
{
int64 to = ourTime;
to -= packet.nettime();
cLog(lsDEBUG) << "Connect: time offset " << to;
WriteLog (lsDEBUG, Peer) << "Connect: time offset " << to;
}
#endif
if ((packet.has_testnet() && packet.testnet()) != theConfig.TESTNET)
{
// Format: actual/requested.
cLog(lsINFO) << boost::str(boost::format("Recv(Hello): Network mismatch: %d/%d")
WriteLog (lsINFO, Peer) << boost::str(boost::format("Recv(Hello): Network mismatch: %d/%d")
% packet.testnet()
% theConfig.TESTNET);
}
@@ -722,31 +721,31 @@ void Peer::recvHello(ripple::TMHello& packet)
{
if (packet.nettime() > maxTime)
{
cLog(lsINFO) << "Recv(Hello): " << getIP() << " :Clock far off +" << packet.nettime() - ourTime;
WriteLog (lsINFO, Peer) << "Recv(Hello): " << getIP() << " :Clock far off +" << packet.nettime() - ourTime;
}
else if(packet.nettime() < minTime)
{
cLog(lsINFO) << "Recv(Hello): " << getIP() << " :Clock far off -" << ourTime - packet.nettime();
WriteLog (lsINFO, Peer) << "Recv(Hello): " << getIP() << " :Clock far off -" << ourTime - packet.nettime();
}
}
else if (packet.protoversionmin() > MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR))
{
cLog(lsINFO) << "Recv(Hello): Server requires protocol version " <<
WriteLog (lsINFO, Peer) << "Recv(Hello): Server requires protocol version " <<
GET_VERSION_MAJOR(packet.protoversion()) << "." << GET_VERSION_MINOR(packet.protoversion())
<< " we run " << PROTO_VERSION_MAJOR << "." << PROTO_VERSION_MINOR;
}
else if (!mNodePublic.setNodePublic(packet.nodepublic()))
{
cLog(lsINFO) << "Recv(Hello): Disconnect: Bad node public key.";
WriteLog (lsINFO, Peer) << "Recv(Hello): Disconnect: Bad node public key.";
}
else if (!mNodePublic.verifyNodePublic(mCookieHash, packet.nodeproof()))
{ // Unable to verify they have private key for claimed public key.
cLog(lsINFO) << "Recv(Hello): Disconnect: Failed to verify session.";
WriteLog (lsINFO, Peer) << "Recv(Hello): Disconnect: Failed to verify session.";
}
else
{ // Successful connection.
cLog(lsINFO) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic();
tLog(packet.protoversion() != MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR), lsINFO)
WriteLog (lsINFO, Peer) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic();
CondLog (packet.protoversion() != MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR), lsINFO, Peer)
<< "Peer speaks version " <<
(packet.protoversion() >> 16) << "." << (packet.protoversion() & 0xFF);
mHello = packet;
@@ -754,7 +753,7 @@ void Peer::recvHello(ripple::TMHello& packet)
{
mCluster = true;
mLoad.setPrivileged();
cLog(lsINFO) << "Cluster connection to \"" << (mNodeName.empty() ? getIP() : mNodeName)
WriteLog (lsINFO, Peer) << "Cluster connection to \"" << (mNodeName.empty() ? getIP() : mNodeName)
<< "\" established";
}
if (isOutbound())
@@ -768,7 +767,7 @@ void Peer::recvHello(ripple::TMHello& packet)
if (!theApp->getConnectionPool().peerConnected(shared_from_this(), mNodePublic, getIP(), getPort()))
{ // Already connected, self, or some other reason.
cLog(lsINFO) << "Recv(Hello): Disconnect: Extraneous connection.";
WriteLog (lsINFO, Peer) << "Recv(Hello): Disconnect: Extraneous connection.";
}
else
{
@@ -785,7 +784,7 @@ void Peer::recvHello(ripple::TMHello& packet)
if (mHello.nodeprivate())
{
cLog(lsINFO) << boost::str(boost::format("Recv(Hello): Private connection: %s %s") % strIP % iPort);
WriteLog (lsINFO, Peer) << boost::str(boost::format("Recv(Hello): Private connection: %s %s") % strIP % iPort);
}
else
{
@@ -888,7 +887,7 @@ void Peer::recvTransaction(ripple::TMTransaction& packet, ScopedLock& MasterLock
if ((flags & SF_RETRY) == 0)
return;
}
cLog(lsDEBUG) << "Got new transaction from peer";
WriteLog (lsDEBUG, Peer) << "Got new transaction from peer";
if (mCluster)
flags |= SF_TRUSTED | SF_SIGGOOD;
@@ -917,7 +916,7 @@ static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packe
bool sigGood = false;
bool isTrusted = (job.getType() == jtPROPOSAL_t);
cLog(lsTRACE) << "Checking " << (isTrusted ? "trusted" : "UNtrusted") << " proposal";
WriteLog (lsTRACE, Peer) << "Checking " << (isTrusted ? "trusted" : "UNtrusted") << " proposal";
assert(packet);
ripple::TMProposeSet& set = *packet;
@@ -925,12 +924,12 @@ static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packe
uint256 prevLedger;
if (set.has_previousledger())
{ // proposal includes a previous ledger
cLog(lsTRACE) << "proposal with previous ledger";
WriteLog (lsTRACE, Peer) << "proposal with previous ledger";
memcpy(prevLedger.begin(), set.previousledger().data(), 256 / 8);
if (!proposal->checkSign(set.signature()))
{
Peer::pointer p = peer.lock();
cLog(lsWARNING) << "proposal with previous ledger fails signature check: " <<
WriteLog (lsWARNING, Peer) << "proposal with previous ledger fails signature check: " <<
(p ? p->getIP() : std::string("???"));
Peer::punishPeer(peer, LT_InvalidSignature);
return;
@@ -947,7 +946,7 @@ static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packe
}
else
{
cLog(lsWARNING) << "Ledger proposal fails signature check"; // Could be mismatched prev ledger
WriteLog (lsWARNING, Peer) << "Ledger proposal fails signature check"; // Could be mismatched prev ledger
proposal->setSignature(set.signature());
}
}
@@ -960,14 +959,14 @@ static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packe
}
else if (sigGood && (prevLedger == consensusLCL))
{ // relay untrusted proposal
cLog(lsTRACE) << "relaying untrusted proposal";
WriteLog (lsTRACE, Peer) << "relaying untrusted proposal";
std::set<uint64> peers;
theApp->getSuppression().swapSet(proposal->getSuppression(), peers, SF_RELAYED);
PackedMessage::pointer message = boost::make_shared<PackedMessage>(set, ripple::mtPROPOSE_LEDGER);
theApp->getConnectionPool().relayMessageBut(peers, message);
}
else
cLog(lsDEBUG) << "Not relaying untrusted proposal";
WriteLog (lsDEBUG, Peer) << "Not relaying untrusted proposal";
}
void Peer::recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet)
@@ -978,14 +977,14 @@ void Peer::recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet)
if ((set.currenttxhash().size() != 32) || (set.nodepubkey().size() < 28) ||
(set.signature().size() < 56) || (set.nodepubkey().size() > 128) || (set.signature().size() > 128))
{
cLog(lsWARNING) << "Received proposal is malformed";
WriteLog (lsWARNING, Peer) << "Received proposal is malformed";
punishPeer(LT_InvalidSignature);
return;
}
if (set.has_previousledger() && (set.previousledger().size() != 32))
{
cLog(lsWARNING) << "Received proposal is malformed";
WriteLog (lsWARNING, Peer) << "Received proposal is malformed";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1007,18 +1006,18 @@ void Peer::recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet)
if (!theApp->isNew(suppression, mPeerId))
{
cLog(lsTRACE) << "Received duplicate proposal from peer " << mPeerId;
WriteLog (lsTRACE, Peer) << "Received duplicate proposal from peer " << mPeerId;
return;
}
RippleAddress signerPublic = RippleAddress::createNodePublic(strCopy(set.nodepubkey()));
if (signerPublic == theConfig.VALIDATION_PUB)
{
cLog(lsTRACE) << "Received our own proposal from peer " << mPeerId;
WriteLog (lsTRACE, Peer) << "Received our own proposal from peer " << mPeerId;
return;
}
bool isTrusted = theApp->getUNL().nodeInUNL(signerPublic);
cLog(lsTRACE) << "Received " << (isTrusted ? "trusted" : "UNtrusted") << " proposal from " << mPeerId;
WriteLog (lsTRACE, Peer) << "Received " << (isTrusted ? "trusted" : "UNtrusted") << " proposal from " << mPeerId;
uint256 consensusLCL = theApp->getOPs().getConsensusLCL();
LedgerProposal::pointer proposal = boost::make_shared<LedgerProposal>(
@@ -1055,7 +1054,7 @@ static void checkValidation(Job&, SerializedValidation::pointer val, uint256 sig
{
if (!isCluster && !val->isValid(signingHash))
{
cLog(lsWARNING) << "Validation is invalid";
WriteLog (lsWARNING, Peer) << "Validation is invalid";
Peer::punishPeer(peer, LT_InvalidRequest);
return;
}
@@ -1078,7 +1077,7 @@ static void checkValidation(Job&, SerializedValidation::pointer val, uint256 sig
#ifndef TRUST_NETWORK
catch (...)
{
cLog(lsWARNING) << "Exception processing validation";
WriteLog (lsWARNING, Peer) << "Exception processing validation";
Peer::punishPeer(peer, LT_InvalidRequest);
}
#endif
@@ -1089,7 +1088,7 @@ void Peer::recvValidation(const boost::shared_ptr<ripple::TMValidation>& packet,
MasterLockHolder.unlock();
if (packet->validation().size() < 50)
{
cLog(lsWARNING) << "Too small validation from peer";
WriteLog (lsWARNING, Peer) << "Too small validation from peer";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1105,7 +1104,7 @@ void Peer::recvValidation(const boost::shared_ptr<ripple::TMValidation>& packet,
uint256 signingHash = val->getSigningHash();
if (!theApp->isNew(signingHash, mPeerId))
{
cLog(lsTRACE) << "Validation is duplicate";
WriteLog (lsTRACE, Peer) << "Validation is duplicate";
return;
}
@@ -1117,7 +1116,7 @@ void Peer::recvValidation(const boost::shared_ptr<ripple::TMValidation>& packet,
#ifndef TRUST_NETWORK
catch (...)
{
cLog(lsWARNING) << "Exception processing validation";
WriteLog (lsWARNING, Peer) << "Exception processing validation";
punishPeer(LT_InvalidRequest);
}
#endif
@@ -1161,7 +1160,7 @@ void Peer::recvGetPeers(ripple::TMGetPeers& packet, ScopedLock& MasterLockHolder
addr->set_ipv4(inet_addr(strIP.c_str()));
addr->set_ipv4port(iPort);
//cLog(lsINFO) << "Peer: Teaching: " << ADDRESS(this) << ": " << n << ": " << strIP << " " << iPort;
//WriteLog (lsINFO, Peer) << "Peer: Teaching: " << ADDRESS(this) << ": " << n << ": " << strIP << " " << iPort;
}
PackedMessage::pointer message = boost::make_shared<PackedMessage>(peers, ripple::mtPEERS);
@@ -1183,7 +1182,7 @@ void Peer::recvPeers(ripple::TMPeers& packet)
if (strIP != "0.0.0.0" && strIP != "127.0.0.1")
{
//cLog(lsINFO) << "Peer: Learning: " << ADDRESS(this) << ": " << i << ": " << strIP << " " << iPort;
//WriteLog (lsINFO, Peer) << "Peer: Learning: " << ADDRESS(this) << ": " << i << ": " << strIP << " " << iPort;
theApp->getConnectionPool().savePeer(strIP, iPort, UniqueNodeList::vsTold);
}
@@ -1231,7 +1230,7 @@ void Peer::recvGetObjectByHash(const boost::shared_ptr<ripple::TMGetObjectByHash
}
}
}
cLog(lsTRACE) << "GetObjByHash had " << reply.objects_size() << " of " << packet.objects_size()
WriteLog (lsTRACE, Peer) << "GetObjByHash had " << reply.objects_size() << " of " << packet.objects_size()
<< " for " << getIP();
sendPacket(boost::make_shared<PackedMessage>(reply, ripple::mtGET_OBJECTS), true);
}
@@ -1250,12 +1249,12 @@ void Peer::recvGetObjectByHash(const boost::shared_ptr<ripple::TMGetObjectByHash
{
if (obj.ledgerseq() != pLSeq)
{
tLog(pLDo && (pLSeq != 0), lsDEBUG) << "Recevied full fetch pack for " << pLSeq;
CondLog (pLDo && (pLSeq != 0), lsDEBUG, Peer) << "Recevied full fetch pack for " << pLSeq;
pLSeq = obj.ledgerseq();
pLDo = !theApp->getOPs().haveLedger(pLSeq);
if (!pLDo)
{
cLog(lsDEBUG) << "Got pack for " << pLSeq << " too late";
WriteLog (lsDEBUG, Peer) << "Got pack for " << pLSeq << " too late";
}
else
progress = true;
@@ -1274,7 +1273,7 @@ void Peer::recvGetObjectByHash(const boost::shared_ptr<ripple::TMGetObjectByHash
}
}
}
tLog(pLDo && (pLSeq != 0), lsDEBUG) << "Received partial fetch pack for " << pLSeq;
CondLog (pLDo && (pLSeq != 0), lsDEBUG, Peer) << "Received partial fetch pack for " << pLSeq;
if (packet.type() == ripple::TMGetObjectByHash::otFETCH_PACK)
theApp->getOPs().gotFetchPack(progress, pLSeq);
}
@@ -1365,12 +1364,12 @@ void Peer::recvProofWork(ripple::TMProofWork& packet)
return;
}
cLog(lsINFO) << "Received in valid proof of work object from peer";
WriteLog (lsINFO, Peer) << "Received in valid proof of work object from peer";
}
void Peer::recvStatus(ripple::TMStatusChange& packet)
{
cLog(lsTRACE) << "Received status change from peer " << getIP();
WriteLog (lsTRACE, Peer) << "Received status change from peer " << getIP();
if (!packet.has_networktime())
packet.set_networktime(theApp->getOPs().getNetworkTimeNC());
@@ -1387,7 +1386,7 @@ void Peer::recvStatus(ripple::TMStatusChange& packet)
{
if (!mClosedLedgerHash.isZero())
{
cLog(lsTRACE) << "peer has lost sync " << getIP();
WriteLog (lsTRACE, Peer) << "peer has lost sync " << getIP();
mClosedLedgerHash.zero();
}
mPreviousLedgerHash.zero();
@@ -1397,11 +1396,11 @@ void Peer::recvStatus(ripple::TMStatusChange& packet)
{ // a peer has changed ledgers
memcpy(mClosedLedgerHash.begin(), packet.ledgerhash().data(), 256 / 8);
addLedger(mClosedLedgerHash);
cLog(lsTRACE) << "peer LCL is " << mClosedLedgerHash << " " << getIP();
WriteLog (lsTRACE, Peer) << "peer LCL is " << mClosedLedgerHash << " " << getIP();
}
else
{
cLog(lsTRACE) << "peer has no ledger hash" << getIP();
WriteLog (lsTRACE, Peer) << "peer has no ledger hash" << getIP();
mClosedLedgerHash.zero();
}
@@ -1431,11 +1430,11 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if (packet.itype() == ripple::liTS_CANDIDATE)
{ // Request is for a transaction candidate set
cLog(lsDEBUG) << "Received request for TX candidate set data " << getIP();
WriteLog (lsDEBUG, Peer) << "Received request for TX candidate set data " << getIP();
if ((!packet.has_ledgerhash() || packet.ledgerhash().size() != 32))
{
punishPeer(LT_InvalidRequest);
cLog(lsWARNING) << "invalid request for TX candidate set data";
WriteLog (lsWARNING, Peer) << "invalid request for TX candidate set data";
return;
}
uint256 txHash;
@@ -1445,7 +1444,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
{
if (packet.has_querytype() && !packet.has_requestcookie())
{
cLog(lsDEBUG) << "Trying to route TX set request";
WriteLog (lsDEBUG, Peer) << "Trying to route TX set request";
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
std::vector<Peer::pointer> usablePeers;
BOOST_FOREACH(Peer::ref peer, peerList)
@@ -1455,7 +1454,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
}
if (usablePeers.empty())
{
cLog(lsINFO) << "Unable to route TX set request";
WriteLog (lsINFO, Peer) << "Unable to route TX set request";
return;
}
Peer::ref selectedPeer = usablePeers[rand() % usablePeers.size()];
@@ -1463,7 +1462,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
selectedPeer->sendPacket(boost::make_shared<PackedMessage>(packet, ripple::mtGET_LEDGER), false);
return;
}
cLog(lsERROR) << "We do not have the map our peer wants " << getIP();
WriteLog (lsERROR, Peer) << "We do not have the map our peer wants " << getIP();
punishPeer(LT_InvalidRequest);
return;
}
@@ -1475,7 +1474,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
}
else
{ // Figure out what ledger they want
cLog(lsTRACE) << "Received request for ledger data " << getIP();
WriteLog (lsTRACE, Peer) << "Received request for ledger data " << getIP();
Ledger::pointer ledger;
if (packet.has_ledgerhash())
{
@@ -1483,14 +1482,14 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if (packet.ledgerhash().size() != 32)
{
punishPeer(LT_InvalidRequest);
cLog(lsWARNING) << "Invalid request";
WriteLog (lsWARNING, Peer) << "Invalid request";
return;
}
memcpy(ledgerhash.begin(), packet.ledgerhash().data(), 32);
logMe += "LedgerHash:"; logMe += ledgerhash.GetHex();
ledger = theApp->getLedgerMaster().getLedgerByHash(ledgerhash);
tLog(!ledger, lsTRACE) << "Don't have ledger " << ledgerhash;
CondLog (!ledger, lsTRACE, Peer) << "Don't have ledger " << ledgerhash;
if (!ledger && (packet.has_querytype() && !packet.has_requestcookie()))
{
uint32 seq = 0;
@@ -1505,20 +1504,20 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
}
if (usablePeers.empty())
{
cLog(lsTRACE) << "Unable to route ledger request";
WriteLog (lsTRACE, Peer) << "Unable to route ledger request";
return;
}
Peer::ref selectedPeer = usablePeers[rand() % usablePeers.size()];
packet.set_requestcookie(getPeerId());
selectedPeer->sendPacket(boost::make_shared<PackedMessage>(packet, ripple::mtGET_LEDGER), false);
cLog(lsDEBUG) << "Ledger request routed";
WriteLog (lsDEBUG, Peer) << "Ledger request routed";
return;
}
}
else if (packet.has_ledgerseq())
{
ledger = theApp->getLedgerMaster().getLedgerBySeq(packet.ledgerseq());
tLog(!ledger, lsDEBUG) << "Don't have ledger " << packet.ledgerseq();
CondLog (!ledger, lsDEBUG, Peer) << "Don't have ledger " << packet.ledgerseq();
}
else if (packet.has_ltype() && (packet.ltype() == ripple::ltCURRENT))
ledger = theApp->getLedgerMaster().getCurrentLedger();
@@ -1531,14 +1530,14 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
else
{
punishPeer(LT_InvalidRequest);
cLog(lsWARNING) << "Can't figure out what ledger they want";
WriteLog (lsWARNING, Peer) << "Can't figure out what ledger they want";
return;
}
if ((!ledger) || (packet.has_ledgerseq() && (packet.ledgerseq() != ledger->getLedgerSeq())))
{
punishPeer(LT_InvalidRequest);
if (sLog(lsWARNING))
if (ShouldLog (lsWARNING, Peer))
{
if (ledger)
Log(lsWARNING) << "Ledger has wrong sequence";
@@ -1550,7 +1549,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
MasterLockHolder.unlock();
else
{
cLog(lsWARNING) << "Request for data from mutable ledger";
WriteLog (lsWARNING, Peer) << "Request for data from mutable ledger";
}
// Fill out the reply
@@ -1561,7 +1560,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if(packet.itype() == ripple::liBASE)
{ // they want the ledger base data
cLog(lsTRACE) << "They want ledger base data";
WriteLog (lsTRACE, Peer) << "They want ledger base data";
Serializer nData(128);
ledger->addRaw(nData);
reply.add_nodes()->set_nodedata(nData.getDataPtr(), nData.getLength());
@@ -1605,18 +1604,18 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if ((!map) || (packet.nodeids_size() == 0))
{
cLog(lsWARNING) << "Can't find map or empty request";
WriteLog (lsWARNING, Peer) << "Can't find map or empty request";
punishPeer(LT_InvalidRequest);
return;
}
cLog(lsTRACE) << "Request: " << logMe;
WriteLog (lsTRACE, Peer) << "Request: " << logMe;
for(int i = 0; i < packet.nodeids().size(); ++i)
{
SHAMapNode mn(packet.nodeids(i).data(), packet.nodeids(i).size());
if(!mn.isValid())
{
cLog(lsWARNING) << "Request for invalid node: " << logMe;
WriteLog (lsWARNING, Peer) << "Request for invalid node: " << logMe;
punishPeer(LT_InvalidRequest);
return;
}
@@ -1627,7 +1626,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if(map->getNodeFat(mn, nodeIDs, rawNodes, fatRoot, fatLeaves))
{
assert(nodeIDs.size() == rawNodes.size());
cLog(lsTRACE) << "getNodeFat got " << rawNodes.size() << " nodes";
WriteLog (lsTRACE, Peer) << "getNodeFat got " << rawNodes.size() << " nodes";
std::vector<SHAMapNode>::iterator nodeIDIterator;
std::list< std::vector<unsigned char> >::iterator rawNodeIterator;
for(nodeIDIterator = nodeIDs.begin(), rawNodeIterator = rawNodes.begin();
@@ -1641,7 +1640,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
}
}
else
cLog(lsWARNING) << "getNodeFat returns false";
WriteLog (lsWARNING, Peer) << "getNodeFat returns false";
}
catch (std::exception& e)
{
@@ -1658,7 +1657,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet, ScopedLock& MasterLockHold
if (!packet.has_ledgerhash())
info += ", no hash specified";
cLog(lsWARNING) << "getNodeFat( " << mn <<") throws exception: " << info;
WriteLog (lsWARNING, Peer) << "getNodeFat( " << mn <<") throws exception: " << info;
}
}
PackedMessage::pointer oPacket = boost::make_shared<PackedMessage>(reply, ripple::mtLEDGER_DATA);
@@ -1671,7 +1670,7 @@ void Peer::recvLedger(const boost::shared_ptr<ripple::TMLedgerData>& packet_ptr,
ripple::TMLedgerData& packet = *packet_ptr;
if (packet.nodes().size() <= 0)
{
cLog(lsWARNING) << "Ledger/TXset data with no nodes";
WriteLog (lsWARNING, Peer) << "Ledger/TXset data with no nodes";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1686,7 +1685,7 @@ void Peer::recvLedger(const boost::shared_ptr<ripple::TMLedgerData>& packet_ptr,
}
else
{
cLog(lsINFO) << "Unable to route TX/ledger data reply";
WriteLog (lsINFO, Peer) << "Unable to route TX/ledger data reply";
punishPeer(LT_UnwantedData);
}
return;
@@ -1695,7 +1694,7 @@ void Peer::recvLedger(const boost::shared_ptr<ripple::TMLedgerData>& packet_ptr,
uint256 hash;
if(packet.ledgerhash().size() != 32)
{
cLog(lsWARNING) << "TX candidate reply with invalid hash size";
WriteLog (lsWARNING, Peer) << "TX candidate reply with invalid hash size";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1711,7 +1710,7 @@ void Peer::recvLedger(const boost::shared_ptr<ripple::TMLedgerData>& packet_ptr,
const ripple::TMLedgerNode& node = packet.nodes(i);
if (!node.has_nodeid() || !node.has_nodedata() || (node.nodeid().size() != 33))
{
cLog(lsWARNING) << "LedgerData request with invalid node ID";
WriteLog (lsWARNING, Peer) << "LedgerData request with invalid node ID";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1862,7 +1861,7 @@ void Peer::doProofOfWork(Job&, boost::weak_ptr<Peer> peer, ProofOfWork::pointer
uint256 solution = pow->solve();
if (solution.isZero())
{
cLog(lsWARNING) << "Failed to solve proof of work";
WriteLog (lsWARNING, Peer) << "Failed to solve proof of work";
}
else
{
@@ -1885,12 +1884,12 @@ void Peer::doFetchPack(const boost::shared_ptr<ripple::TMGetObjectByHash>& packe
{
if (theApp->getFeeTrack().isLoaded())
{
cLog(lsINFO) << "Too busy to make fetch pack";
WriteLog (lsINFO, Peer) << "Too busy to make fetch pack";
return;
}
if (packet->ledgerhash().size() != 32)
{
cLog(lsWARNING) << "FetchPack hash size malformed";
WriteLog (lsWARNING, Peer) << "FetchPack hash size malformed";
punishPeer(LT_InvalidRequest);
return;
}
@@ -1900,13 +1899,13 @@ void Peer::doFetchPack(const boost::shared_ptr<ripple::TMGetObjectByHash>& packe
Ledger::pointer haveLedger = theApp->getOPs().getLedgerByHash(hash);
if (!haveLedger)
{
cLog(lsINFO) << "Peer requests fetch pack for ledger we don't have: " << hash;
WriteLog (lsINFO, Peer) << "Peer requests fetch pack for ledger we don't have: " << hash;
punishPeer(LT_RequestNoReply);
return;
}
if (!haveLedger->isClosed())
{
cLog(lsWARNING) << "Peer requests fetch pack from open ledger: " << hash;
WriteLog (lsWARNING, Peer) << "Peer requests fetch pack from open ledger: " << hash;
punishPeer(LT_InvalidRequest);
return;
}
@@ -1914,7 +1913,7 @@ void Peer::doFetchPack(const boost::shared_ptr<ripple::TMGetObjectByHash>& packe
Ledger::pointer wantLedger = theApp->getOPs().getLedgerByHash(haveLedger->getParentHash());
if (!wantLedger)
{
cLog(lsINFO) << "Peer requests fetch pack for ledger whose predecessor we don't have: " << hash;
WriteLog (lsINFO, Peer) << "Peer requests fetch pack for ledger whose predecessor we don't have: " << hash;
punishPeer(LT_RequestNoReply);
return;
}
@@ -1966,7 +1965,7 @@ Json::Value Peer::getJson()
case ripple::nsMONITORING: ret["status"] = "monitoring"; break;
case ripple::nsVALIDATING: ret["status"] = "validating"; break;
case ripple::nsSHUTTING: ret["status"] = "shutting"; break;
default: cLog(lsWARNING) << "Peer has unknown status: " << mLastStatus.newstatus();
default: WriteLog (lsWARNING, Peer) << "Peer has unknown status: " << mLastStatus.newstatus();
}
}

View File

@@ -11,17 +11,9 @@
#include "utils.h"
#include "Log.h"
SETUP_LOG();
using namespace std;
using namespace boost::asio::ip;
// Generate DH for SSL connection.
static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
{
return 512 == iKeyLength ? theApp->getWallet().getDh512() : theApp->getWallet().getDh1024();
}
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
mAcceptor(io_service,
tcp::endpoint(address().from_string(theConfig.PEER_IP.empty() ? "0.0.0.0" : theConfig.PEER_IP),
@@ -67,7 +59,7 @@ void PeerDoor::handleConnect(Peer::pointer new_connection,
{
if (error == boost::system::errc::too_many_files_open)
delay = true;
cLog(lsERROR) << error;
WriteLog (lsERROR, PeerDoor) << error;
}
if (delay)

View File

@@ -64,7 +64,7 @@ public:
mLoadSource(mRemoteIP), mPingTimer(cpConnection->get_io_service()), mPinged(false),
mRcvQueueRunning(false), mDead(false)
{
cLog(lsDEBUG) << "Websocket connection from " << mRemoteIP;
WriteLog (lsDEBUG, WSServerHandlerLog) << "Websocket connection from " << mRemoteIP;
setPingTimer();
}

View File

@@ -1,11 +1,9 @@
#include "Log.h"
#define WSDOOR_CPP
#include "../websocketpp/src/sockets/autotls.hpp"
#include "../websocketpp/src/websocketpp.hpp"
SETUP_LOG();
//#define WSDOOR_CPP
//#include "../websocketpp/src/sockets/autotls.hpp"
//#include "../websocketpp/src/websocketpp.hpp"
#include "Application.h"
#include "Config.h"
@@ -40,12 +38,6 @@ DECLARE_INSTANCE(WebSocketConnection);
// - NetworkOPs is smart enough to subscribe and or pass back messages
//
// Generate DH for SSL connection.
static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
{
return 512 == iKeyLength ? theApp->getWallet().getDh512() : theApp->getWallet().getDh1024();
}
void WSDoor::startListening()
{
NameThread("websocket");
@@ -78,7 +70,7 @@ void WSDoor::startListening()
}
catch (websocketpp::exception& e)
{
cLog(lsWARNING) << "websocketpp exception: " << e.what();
WriteLog (lsWARNING, WSDoor) << "websocketpp exception: " << e.what();
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
{ // https://github.com/zaphoyd/websocketpp/issues/98
try
@@ -88,7 +80,7 @@ void WSDoor::startListening()
}
catch (websocketpp::exception& e)
{
cLog(lsWARNING) << "websocketpp exception: " << e.what();
WriteLog (lsWARNING, WSDoor) << "websocketpp exception: " << e.what();
}
}
}
@@ -100,7 +92,7 @@ WSDoor* WSDoor::createWSDoor(const std::string& strIp, const int iPort, bool bPu
{
WSDoor* wdpResult = new WSDoor(strIp, iPort, bPublic);
cLog(lsINFO) <<
WriteLog (lsINFO, WSDoor) <<
boost::str(boost::format("Websocket: %s: Listening: %s %d ")
% (bPublic ? "Public" : "Private")
% strIp

View File

@@ -7,6 +7,10 @@
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include "../websocketpp/src/sockets/autotls.hpp"
#include "../websocketpp/src/websocketpp.hpp"
/*
#ifndef WSDOOR_CPP
namespace websocketpp
@@ -16,6 +20,7 @@ namespace websocketpp
}
#endif
*/
class WSDoor
{

View File

@@ -13,8 +13,13 @@ class WSConnection;
// CAUTION: on_* functions are called by the websocket code while holding a lock
struct WSServerHandlerLog // for logging
{
};
// A single instance of this object is made.
// This instance dispatches all events. There is no per connection persistence.
template <typename endpoint_type>
class WSServerHandler : public endpoint_type::handler
{
@@ -65,7 +70,7 @@ public:
{
try
{
cLog(broadcast ? lsTRACE : lsDEBUG) << "Ws:: Sending '" << strMessage << "'";
WriteLog (broadcast ? lsTRACE : lsDEBUG, WSServerHandlerLog) << "Ws:: Sending '" << strMessage << "'";
cpClient->send(strMessage);
}
@@ -91,7 +96,7 @@ public:
{
Json::FastWriter jfwWriter;
// cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
// WriteLog (lsDEBUG, WSServerHandlerLog) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
send(cpClient, jfwWriter.write(jvObj), broadcast);
}
@@ -109,7 +114,7 @@ public:
std::string data("ping");
if (ptr->onPingTimer(data))
{
cLog(lsWARNING) << "Connection pings out";
WriteLog (lsWARNING, WSServerHandlerLog) << "Connection pings out";
cpClient->close(websocketpp::close::status::PROTOCOL_ERROR, "ping timeout");
}
else
@@ -185,7 +190,7 @@ public:
{
try
{
cLog(lsDEBUG) << "Ws:: Rejected("
WriteLog (lsDEBUG, WSServerHandlerLog) << "Ws:: Rejected("
<< cpClient->get_socket().lowest_layer().remote_endpoint().address().to_string()
<< ") '" << mpMessage->get_payload() << "'";
}
@@ -227,7 +232,7 @@ public:
try
{
cLog(lsDEBUG) << "Ws:: Receiving("
WriteLog (lsDEBUG, WSServerHandlerLog) << "Ws:: Receiving("
<< cpClient->get_socket().lowest_layer().remote_endpoint().address().to_string()
<< ") '" << mpMessage->get_payload() << "'";
}