mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Move PeerSet members to the right file
This commit is contained in:
@@ -526,58 +526,6 @@ void InboundLedger::trigger (Peer::ref peer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL, Peer::ref peer)
|
|
||||||
{
|
|
||||||
if (!peer)
|
|
||||||
sendRequest (tmGL);
|
|
||||||
else
|
|
||||||
peer->sendPacket (boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL)
|
|
||||||
{
|
|
||||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
|
||||||
|
|
||||||
if (mPeers.empty ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER);
|
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
|
||||||
{
|
|
||||||
Peer::pointer peer = getApp().getPeers ().getPeerById (it->first);
|
|
||||||
|
|
||||||
if (peer)
|
|
||||||
peer->sendPacket (packet, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int PeerSet::takePeerSetFrom (const PeerSet& s)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
mPeers.clear ();
|
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::const_iterator it = s.mPeers.begin (), end = s.mPeers.end ();
|
|
||||||
it != end; ++it)
|
|
||||||
{
|
|
||||||
mPeers.insert (std::make_pair (it->first, 0));
|
|
||||||
++ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PeerSet::getPeerCount () const
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::const_iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
|
||||||
if (getApp().getPeers ().hasPeer (it->first))
|
|
||||||
++ret;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InboundLedger::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& nodeHashes,
|
void InboundLedger::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& nodeHashes,
|
||||||
std::set<SHAMapNode>& recentNodes, int max, bool aggressive)
|
std::set<SHAMapNode>& recentNodes, int max, bool aggressive)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -589,13 +589,13 @@ public:
|
|||||||
LedgerIndex ledgerIndex = 1 + r.nextInt (1024 * 1024);
|
LedgerIndex ledgerIndex = 1 + r.nextInt (1024 * 1024);
|
||||||
|
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
r.nextBlob (hash.begin (), hash.size ());
|
r.fillBitsRandomly (hash.begin (), hash.size ());
|
||||||
|
|
||||||
int const payloadBytes = 1 + r.nextInt (maxPayloadBytes);
|
int const payloadBytes = 1 + r.nextInt (maxPayloadBytes);
|
||||||
|
|
||||||
Blob data (payloadBytes);
|
Blob data (payloadBytes);
|
||||||
|
|
||||||
r.nextBlob (data.data (), payloadBytes);
|
r.fillBitsRandomly (data.data (), payloadBytes);
|
||||||
|
|
||||||
return NodeObject::createObject (type, ledgerIndex, data, hash);
|
return NodeObject::createObject (type, ledgerIndex, data, hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,3 +106,56 @@ bool PeerSet::isActive ()
|
|||||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||||
return !isDone ();
|
return !isDone ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL, Peer::ref peer)
|
||||||
|
{
|
||||||
|
if (!peer)
|
||||||
|
sendRequest (tmGL);
|
||||||
|
else
|
||||||
|
peer->sendPacket (boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL)
|
||||||
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||||
|
|
||||||
|
if (mPeers.empty ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER);
|
||||||
|
|
||||||
|
for (boost::unordered_map<uint64, int>::iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
||||||
|
{
|
||||||
|
Peer::pointer peer = getApp().getPeers ().getPeerById (it->first);
|
||||||
|
|
||||||
|
if (peer)
|
||||||
|
peer->sendPacket (packet, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PeerSet::takePeerSetFrom (const PeerSet& s)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
mPeers.clear ();
|
||||||
|
|
||||||
|
for (boost::unordered_map<uint64, int>::const_iterator it = s.mPeers.begin (), end = s.mPeers.end ();
|
||||||
|
it != end; ++it)
|
||||||
|
{
|
||||||
|
mPeers.insert (std::make_pair (it->first, 0));
|
||||||
|
++ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PeerSet::getPeerCount () const
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
for (boost::unordered_map<uint64, int>::const_iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
||||||
|
if (getApp().getPeers ().hasPeer (it->first))
|
||||||
|
++ret;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user