Decongest the master lock:

* Reduce scope of lock in ledger accept
* Remove duplicate tracking of transaction sets
* Need master lock to secure ledger sequencing
This commit is contained in:
David Schwartz
2015-03-06 13:22:20 -08:00
committed by Nik Bougalis
parent e44e75fa6b
commit 60a7abcef6
6 changed files with 192 additions and 277 deletions

View File

@@ -1146,14 +1146,20 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMHaveTransactionSet> const& m)
memcpy (hash.begin (), m->hash ().data (), 32);
if (m->status () == protocol::tsHAVE)
addTxSet (hash);
{
Application::ScopedLockType lock (getApp ().getMasterLock ());
std::lock_guard<std::mutex> sl(recentLock_);
if (!getApp().getOPs ().hasTXSet (
shared_from_this (), hash, m->status ()))
if (std::find (recentTxSets_.begin (),
recentTxSets_.end (), hash) != recentTxSets_.end ())
{
fee_ = Resource::feeUnwantedData;
return;
}
if (recentTxSets_.size () == 128)
recentTxSets_.pop_front ();
recentTxSets_.push_back (hash);
}
}
@@ -1387,21 +1393,6 @@ PeerImp::addLedger (uint256 const& hash)
recentLedgers_.push_back (hash);
}
void
PeerImp::addTxSet (uint256 const& hash)
{
std::lock_guard<std::mutex> sl(recentLock_);
if (std::find (recentTxSets_.begin (),
recentTxSets_.end (), hash) != recentTxSets_.end ())
return;
if (recentTxSets_.size () == 128)
recentTxSets_.pop_front ();
recentTxSets_.push_back (hash);
}
void
PeerImp::doFetchPack (const std::shared_ptr<protocol::TMGetObjectByHash>& packet)
{