Cleanups:

* Use Throw instead of directly throwing an exception
This commit is contained in:
Nik Bougalis
2016-01-26 13:42:55 -08:00
parent f13668371e
commit 57d6ab091c
2 changed files with 11 additions and 12 deletions

View File

@@ -412,16 +412,14 @@ void LedgerConsensusImp::mapCompleteInternal (
// this will create disputed transactions // this will create disputed transactions
auto it2 = mAcquired.find (mOurPosition->getCurrentHash ()); auto it2 = mAcquired.find (mOurPosition->getCurrentHash ());
if (it2 != mAcquired.end ()) if (it2 == mAcquired.end())
{ LogicError ("We cannot find our own position!");
assert ((it2->first == mOurPosition->getCurrentHash ())
&& it2->second); assert ((it2->first == mOurPosition->getCurrentHash ())
mCompares.insert(hash); && it2->second);
// Our position is not the same as the acquired position mCompares.insert(hash);
createDisputes (it2->second, map); // Our position is not the same as the acquired position
} createDisputes (it2->second, map);
else
assert (false); // We don't have our own position?!
} }
else if (!mOurPosition) else if (!mOurPosition)
JLOG (j_.debug) JLOG (j_.debug)
@@ -437,9 +435,10 @@ void LedgerConsensusImp::mapCompleteInternal (
// Adjust tracking for each peer that takes this position // Adjust tracking for each peer that takes this position
std::vector<NodeID> peers; std::vector<NodeID> peers;
auto const mapHash = map->getHash ().as_uint256();
for (auto& it : mPeerPositions) for (auto& it : mPeerPositions)
{ {
if (it.second->getCurrentHash () == map->getHash ().as_uint256()) if (it.second->getCurrentHash () == mapHash)
peers.push_back (it.second->getPeerID ()); peers.push_back (it.second->getPeerID ());
} }

View File

@@ -448,7 +448,7 @@ void
SerialIter::skip (int length) SerialIter::skip (int length)
{ {
if (remain_ < length) if (remain_ < length)
throw std::runtime_error( Throw<std::runtime_error> (
"invalid SerialIter skip"); "invalid SerialIter skip");
p_ += length; p_ += length;
used_ += length; used_ += length;