mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Prevent a race condition that can cause us to miss an "I have a transaction
set" message if it arrives as we're in the process of generating a new last-closed ledger.
This commit is contained in:
@@ -790,6 +790,14 @@ void LedgerConsensus::startAcquiring(const TransactionAcquire::pointer& acquire)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
||||
BOOST_FOREACH(Peer::ref peer, peerList)
|
||||
{
|
||||
if (peer->hasTxSet(acquire->getHash())
|
||||
acquire->peerHash(peer);
|
||||
}
|
||||
|
||||
acquire->resetTimer();
|
||||
}
|
||||
|
||||
|
||||
27
src/Peer.cpp
27
src/Peer.cpp
@@ -744,8 +744,11 @@ void Peer::recvHaveTxSet(newcoin::TMHaveTransactionSet& packet)
|
||||
punishPeer(PP_INVALID_REQUEST);
|
||||
return;
|
||||
}
|
||||
memcpy(hashes.begin(), packet.hash().data(), 32);
|
||||
if (!theApp->getOPs().hasTXSet(shared_from_this(), hashes, packet.status()))
|
||||
uint256 hash;
|
||||
memcpy(hash.begin(), packet.hash().data(), 32);
|
||||
if (packet.status() == newcoin::tsHAVE)
|
||||
addTxSet(hash);
|
||||
if (!theApp->getOPs().hasTXSet(shared_from_this(), hash, packet.status()))
|
||||
punishPeer(PP_UNWANTED_DATA);
|
||||
}
|
||||
|
||||
@@ -1142,11 +1145,29 @@ void Peer::addLedger(const uint256& hash)
|
||||
BOOST_FOREACH(const uint256& ledger, mRecentLedgers)
|
||||
if (ledger == hash)
|
||||
return;
|
||||
if (mRecentLedgers.size() == 16)
|
||||
if (mRecentLedgers.size() == 128)
|
||||
mRecentLedgers.pop_front();
|
||||
mRecentLedgers.push_back(hash);
|
||||
}
|
||||
|
||||
bool Peer::hasTxSet(const uint256& hash) const
|
||||
{
|
||||
BOOST_FOREACH(const uint256& set, mRecentTxSets)
|
||||
if (set == hash)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Peer::addTxSet(const uint256& hash)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& set, mRecentTxSets)
|
||||
if (set == hash)
|
||||
return;
|
||||
if (mRecentTxSets.size() == 128)
|
||||
mRecentTxSets.pop_front();
|
||||
mRecentTxSets.push_back(hash);
|
||||
}
|
||||
|
||||
// Get session information we can sign to prevent man in the middle attack.
|
||||
// (both sides get the same information, neither side controls it)
|
||||
void Peer::getSessionCookie(std::string& strDst)
|
||||
|
||||
@@ -46,6 +46,7 @@ private:
|
||||
|
||||
uint256 mClosedLedgerHash, mPreviousLedgerHash;
|
||||
std::list<uint256> mRecentLedgers;
|
||||
std::list<uint256> mRecentTxSets;
|
||||
|
||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> mSocketSsl;
|
||||
|
||||
@@ -118,6 +119,7 @@ protected:
|
||||
void getSessionCookie(std::string& strDst);
|
||||
|
||||
void addLedger(const uint256& ledger);
|
||||
void addTxSet(const uint256& TxSet);
|
||||
|
||||
public:
|
||||
|
||||
@@ -157,6 +159,7 @@ public:
|
||||
|
||||
uint256 getClosedLedgerHash() const { return mClosedLedgerHash; }
|
||||
bool hasLedger(const uint256& hash) const;
|
||||
bool hasTxSet(const uint256& hash) const;
|
||||
NewcoinAddress getNodePublic() const { return mNodePublic; }
|
||||
void cycleStatus() { mPreviousLedgerHash = mClosedLedgerHash; mClosedLedgerHash.zero(); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user