mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Replace a macro
This commit is contained in:
@@ -4,21 +4,18 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
// VFALCO TODO make this an inline function
|
|
||||||
#define ADDRESS_SHARED(p) strHex(uint64( ((char*) (p).get()) - ((char*) 0)))
|
|
||||||
|
|
||||||
// How often to enforce policies.
|
|
||||||
#define POLICY_INTERVAL_SECONDS 5
|
|
||||||
|
|
||||||
class Peers;
|
|
||||||
|
|
||||||
SETUP_LOG (Peers)
|
|
||||||
|
|
||||||
class Peers
|
class Peers
|
||||||
: public IPeers
|
: public IPeers
|
||||||
, LeakChecked <Peers>
|
, LeakChecked <Peers>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/** Frequency of policy enforcement.
|
||||||
|
*/
|
||||||
|
policyIntervalSeconds = 5
|
||||||
|
};
|
||||||
|
|
||||||
explicit Peers (boost::asio::io_service& io_service)
|
explicit Peers (boost::asio::io_service& io_service)
|
||||||
: mLastPeer (0)
|
: mLastPeer (0)
|
||||||
, mPhase (0)
|
, mPhase (0)
|
||||||
@@ -330,7 +327,7 @@ void Peers::policyEnforce ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Schedule next enforcement.
|
// Schedule next enforcement.
|
||||||
mPolicyTimer.expires_at (boost::posix_time::second_clock::universal_time () + boost::posix_time::seconds (POLICY_INTERVAL_SECONDS));
|
mPolicyTimer.expires_at (boost::posix_time::second_clock::universal_time () + boost::posix_time::seconds (policyIntervalSeconds));
|
||||||
mPolicyTimer.async_wait (BIND_TYPE (&Peers::policyHandler, this, P_1));
|
mPolicyTimer.async_wait (BIND_TYPE (&Peers::policyHandler, this, P_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,7 +500,7 @@ bool Peers::peerConnected (Peer::ref peer, const RippleAddress& naPeer,
|
|||||||
|
|
||||||
if (naPeer == getApp().getLocalCredentials ().getNodePublic ())
|
if (naPeer == getApp().getLocalCredentials ().getNodePublic ())
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, Peers) << "Pool: Connected: self: " << ADDRESS_SHARED (peer) << ": " << naPeer.humanNodePublic () << " " << strIP << " " << iPort;
|
WriteLog (lsINFO, Peers) << "Pool: Connected: self: " << addressToString (peer.get()) << ": " << naPeer.humanNodePublic () << " " << strIP << " " << iPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -513,7 +510,7 @@ bool Peers::peerConnected (Peer::ref peer, const RippleAddress& naPeer,
|
|||||||
if (itCm == mConnectedMap.end ())
|
if (itCm == mConnectedMap.end ())
|
||||||
{
|
{
|
||||||
// New connection.
|
// New connection.
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Connected: new: " << ADDRESS_SHARED(peer) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Connected: new: " << addressToString (peer.get()) << ": " << naPeer.humanNodePublic() << " " << strIP << " " << iPort;
|
||||||
|
|
||||||
mConnectedMap[naPeer] = peer;
|
mConnectedMap[naPeer] = peer;
|
||||||
bNew = true;
|
bNew = true;
|
||||||
@@ -529,7 +526,7 @@ bool Peers::peerConnected (Peer::ref peer, const RippleAddress& naPeer,
|
|||||||
if (itCm->second->getIP ().empty ())
|
if (itCm->second->getIP ().empty ())
|
||||||
{
|
{
|
||||||
// Old peer did not know it's IP.
|
// Old peer did not know it's IP.
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: outbound: " << ADDRESS_SHARED(peer) << " discovered: " << ADDRESS_SHARED(itCm->second) << ": " << strIP << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: outbound: " << addressToString (peer.get()) << " discovered: " << addressToString(itCm->second) << ": " << strIP << " " << iPort;
|
||||||
|
|
||||||
itCm->second->setIpPort (strIP, iPort);
|
itCm->second->setIpPort (strIP, iPort);
|
||||||
|
|
||||||
@@ -539,14 +536,14 @@ bool Peers::peerConnected (Peer::ref peer, const RippleAddress& naPeer,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Old peer knew its IP. Do nothing.
|
// Old peer knew its IP. Do nothing.
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: outbound: rediscovered: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: outbound: rediscovered: " << addressToString (peer.get()) << " " << strIP << " " << iPort;
|
||||||
|
|
||||||
nothing ();
|
nothing ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: inbound: " << ADDRESS_SHARED(peer) << " " << strIP << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Connected: redundant: inbound: " << addressToString (peer.get()) << " " << strIP << " " << iPort;
|
||||||
|
|
||||||
nothing ();
|
nothing ();
|
||||||
}
|
}
|
||||||
@@ -669,13 +666,13 @@ void Peers::peerClosed (Peer::ref peer, const std::string& strIp, int iPort)
|
|||||||
if (itIp == mIpMap.end ())
|
if (itIp == mIpMap.end ())
|
||||||
{
|
{
|
||||||
// Did not find it. Not already connecting or connected.
|
// Did not find it. Not already connecting or connected.
|
||||||
WriteLog (lsWARNING, Peers) << "Pool: Closed: UNEXPECTED: " << ADDRESS_SHARED (peer) << ": " << strIp << " " << iPort;
|
WriteLog (lsWARNING, Peers) << "Pool: Closed: UNEXPECTED: " << addressToString (peer.get()) << ": " << strIp << " " << iPort;
|
||||||
// XXX Internal error.
|
// XXX Internal error.
|
||||||
}
|
}
|
||||||
else if (mIpMap[ipPeer] == peer)
|
else if (mIpMap[ipPeer] == peer)
|
||||||
{
|
{
|
||||||
// We were the identified connection.
|
// We were the identified connection.
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Closed: identified: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Closed: identified: " << addressToString (peer.get()) << ": " << strIp << " " << iPort;
|
||||||
|
|
||||||
// Delete our entry.
|
// Delete our entry.
|
||||||
mIpMap.erase (itIp);
|
mIpMap.erase (itIp);
|
||||||
@@ -685,7 +682,7 @@ void Peers::peerClosed (Peer::ref peer, const std::string& strIp, int iPort)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Found it. But, we were redundant.
|
// Found it. But, we were redundant.
|
||||||
//WriteLog (lsINFO, Peers) << "Pool: Closed: redundant: " << ADDRESS_SHARED(peer) << ": " << strIp << " " << iPort;
|
//WriteLog (lsINFO, Peers) << "Pool: Closed: redundant: " << addressToString (peer.get()) << ": " << strIp << " " << iPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,7 +706,7 @@ void Peers::peerVerified (Peer::ref peer)
|
|||||||
|
|
||||||
std::string strIpPort = str (boost::format ("%s %d") % strIp % iPort);
|
std::string strIpPort = str (boost::format ("%s %d") % strIp % iPort);
|
||||||
|
|
||||||
//WriteLog (lsINFO, Peers) << str(boost::format("Pool: Scan: connected: %s %s %s (scanned)") % ADDRESS_SHARED(peer) % strIp % iPort);
|
//WriteLog (lsINFO, Peers) << str(boost::format("Pool: Scan: connected: %s %s %s (scanned)") % addressToString (peer.get()) % strIp % iPort);
|
||||||
|
|
||||||
if (peer->getNodePublic () == getApp().getLocalCredentials ().getNodePublic ())
|
if (peer->getNodePublic () == getApp().getLocalCredentials ().getNodePublic ())
|
||||||
{
|
{
|
||||||
@@ -880,4 +877,5 @@ bool Peers::isMessageKnown (PackedMessage::pointer msg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim:ts=4
|
SETUP_LOG (Peers)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user