mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'feature-keyvadb' into develop
Conflicts: src/cpp/ripple/RPCHandler.cpp src/cpp/ripple/RPCHandler.h
This commit is contained in:
@@ -42,47 +42,52 @@ NetworkOPs::NetworkOPs (LedgerMaster* pLedgerMaster)
|
||||
|
||||
void NetworkOPs::processNetTimer ()
|
||||
{
|
||||
ScopedLock sl (getApp().getMasterLock ());
|
||||
|
||||
getApp().getLoadManager ().resetDeadlockDetector ();
|
||||
|
||||
std::size_t const numPeers = getApp().getPeers ().getPeerVector ().size ();
|
||||
|
||||
// do we have sufficient peers? If not, we are disconnected.
|
||||
if (numPeers < theConfig.NETWORK_QUORUM)
|
||||
{
|
||||
if (mMode != omDISCONNECTED)
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
// VFALCO NOTE This is for diagnosing a crash on exit
|
||||
Application& app (getApp ());
|
||||
ILoadManager& mgr (app.getLoadManager ());
|
||||
mgr.resetDeadlockDetector ();
|
||||
|
||||
std::size_t const numPeers = getApp().getPeers ().getPeerVector ().size ();
|
||||
|
||||
// do we have sufficient peers? If not, we are disconnected.
|
||||
if (numPeers < theConfig.NETWORK_QUORUM)
|
||||
{
|
||||
setMode (omDISCONNECTED);
|
||||
WriteLog (lsWARNING, NetworkOPs)
|
||||
<< "Node count (" << numPeers << ") "
|
||||
<< "has fallen below quorum (" << theConfig.NETWORK_QUORUM << ").";
|
||||
if (mMode != omDISCONNECTED)
|
||||
{
|
||||
setMode (omDISCONNECTED);
|
||||
WriteLog (lsWARNING, NetworkOPs)
|
||||
<< "Node count (" << numPeers << ") "
|
||||
<< "has fallen below quorum (" << theConfig.NETWORK_QUORUM << ").";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (mMode == omDISCONNECTED)
|
||||
{
|
||||
setMode (omCONNECTED);
|
||||
WriteLog (lsINFO, NetworkOPs) << "Node count (" << numPeers << ") is sufficient.";
|
||||
}
|
||||
|
||||
if (mMode == omDISCONNECTED)
|
||||
{
|
||||
setMode (omCONNECTED);
|
||||
WriteLog (lsINFO, NetworkOPs) << "Node count (" << numPeers << ") is sufficient.";
|
||||
}
|
||||
// Check if the last validated ledger forces a change between these states
|
||||
if (mMode == omSYNCING)
|
||||
{
|
||||
setMode (omSYNCING);
|
||||
}
|
||||
else if (mMode == omCONNECTED)
|
||||
{
|
||||
setMode (omCONNECTED);
|
||||
}
|
||||
|
||||
// Check if the last validated ledger forces a change between these states
|
||||
if (mMode == omSYNCING)
|
||||
{
|
||||
setMode (omSYNCING);
|
||||
}
|
||||
else if (mMode == omCONNECTED)
|
||||
{
|
||||
setMode (omCONNECTED);
|
||||
}
|
||||
if (!mConsensus)
|
||||
tryStartConsensus ();
|
||||
|
||||
if (!mConsensus)
|
||||
tryStartConsensus ();
|
||||
|
||||
if (mConsensus)
|
||||
mConsensus->timerEntry ();
|
||||
if (mConsensus)
|
||||
mConsensus->timerEntry ();
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOPs::onDeadlineTimer (DeadlineTimer& timer)
|
||||
@@ -306,71 +311,72 @@ void NetworkOPs::runTransactionQueue ()
|
||||
{
|
||||
LoadEvent::autoptr ev = getApp().getJobQueue ().getLoadEventAP (jtTXN_PROC, "runTxnQ");
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
|
||||
Transaction::pointer dbtx = getApp().getMasterTransaction ().fetch (txn->getID (), true);
|
||||
assert (dbtx);
|
||||
|
||||
bool didApply;
|
||||
TER r = mLedgerMaster->doTransaction (dbtx->getSTransaction (),
|
||||
tapOPEN_LEDGER | tapNO_CHECK_SIGN, didApply);
|
||||
dbtx->setResult (r);
|
||||
|
||||
if (isTemMalformed (r)) // malformed, cache bad
|
||||
getApp().getHashRouter ().setFlag (txn->getID (), SF_BAD);
|
||||
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||
// getApp().getHashRouter ().setFlag (txn->getID (), SF_RETRY);
|
||||
|
||||
|
||||
if (isTerRetry (r))
|
||||
{
|
||||
// transaction should be held
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "QTransaction should be held: " << r;
|
||||
dbtx->setStatus (HELD);
|
||||
getApp().getMasterTransaction ().canonicalize (dbtx);
|
||||
mLedgerMaster->addHeldTransaction (dbtx);
|
||||
}
|
||||
else if (r == tefPAST_SEQ)
|
||||
{
|
||||
// duplicate or conflict
|
||||
WriteLog (lsINFO, NetworkOPs) << "QTransaction is obsolete";
|
||||
dbtx->setStatus (OBSOLETE);
|
||||
}
|
||||
else if (r == tesSUCCESS)
|
||||
{
|
||||
WriteLog (lsINFO, NetworkOPs) << "QTransaction is now included in open ledger";
|
||||
dbtx->setStatus (INCLUDED);
|
||||
getApp().getMasterTransaction ().canonicalize (dbtx);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "QStatus other than success " << r;
|
||||
dbtx->setStatus (INVALID);
|
||||
}
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
// if (didApply || (mMode != omFULL))
|
||||
if (didApply)
|
||||
{
|
||||
std::set<uint64> peers;
|
||||
Transaction::pointer dbtx = getApp().getMasterTransaction ().fetch (txn->getID (), true);
|
||||
assert (dbtx);
|
||||
|
||||
if (getApp().getHashRouter ().swapSet (txn->getID (), peers, SF_RELAYED))
|
||||
bool didApply;
|
||||
TER r = mLedgerMaster->doTransaction (dbtx->getSTransaction (),
|
||||
tapOPEN_LEDGER | tapNO_CHECK_SIGN, didApply);
|
||||
dbtx->setResult (r);
|
||||
|
||||
if (isTemMalformed (r)) // malformed, cache bad
|
||||
getApp().getHashRouter ().setFlag (txn->getID (), SF_BAD);
|
||||
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||
// getApp().getHashRouter ().setFlag (txn->getID (), SF_RETRY);
|
||||
|
||||
|
||||
if (isTerRetry (r))
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "relaying";
|
||||
protocol::TMTransaction tx;
|
||||
Serializer s;
|
||||
dbtx->getSTransaction ()->add (s);
|
||||
tx.set_rawtransaction (&s.getData ().front (), s.getLength ());
|
||||
tx.set_status (protocol::tsCURRENT);
|
||||
tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it
|
||||
|
||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tx, protocol::mtTRANSACTION);
|
||||
getApp().getPeers ().relayMessageBut (peers, packet);
|
||||
// transaction should be held
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "QTransaction should be held: " << r;
|
||||
dbtx->setStatus (HELD);
|
||||
getApp().getMasterTransaction ().canonicalize (dbtx);
|
||||
mLedgerMaster->addHeldTransaction (dbtx);
|
||||
}
|
||||
else if (r == tefPAST_SEQ)
|
||||
{
|
||||
// duplicate or conflict
|
||||
WriteLog (lsINFO, NetworkOPs) << "QTransaction is obsolete";
|
||||
dbtx->setStatus (OBSOLETE);
|
||||
}
|
||||
else if (r == tesSUCCESS)
|
||||
{
|
||||
WriteLog (lsINFO, NetworkOPs) << "QTransaction is now included in open ledger";
|
||||
dbtx->setStatus (INCLUDED);
|
||||
getApp().getMasterTransaction ().canonicalize (dbtx);
|
||||
}
|
||||
else
|
||||
WriteLog(lsDEBUG, NetworkOPs) << "recently relayed";
|
||||
}
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "QStatus other than success " << r;
|
||||
dbtx->setStatus (INVALID);
|
||||
}
|
||||
|
||||
txn->doCallbacks (r);
|
||||
if (didApply /*|| (mMode != omFULL)*/ )
|
||||
{
|
||||
std::set <uint64> peers;
|
||||
|
||||
if (getApp().getHashRouter ().swapSet (txn->getID (), peers, SF_RELAYED))
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "relaying";
|
||||
protocol::TMTransaction tx;
|
||||
Serializer s;
|
||||
dbtx->getSTransaction ()->add (s);
|
||||
tx.set_rawtransaction (&s.getData ().front (), s.getLength ());
|
||||
tx.set_status (protocol::tsCURRENT);
|
||||
tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it
|
||||
|
||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tx, protocol::mtTRANSACTION);
|
||||
getApp().getPeers ().relayMessageBut (peers, packet);
|
||||
}
|
||||
else
|
||||
WriteLog(lsDEBUG, NetworkOPs) << "recently relayed";
|
||||
}
|
||||
|
||||
txn->doCallbacks (r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,77 +413,79 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
|
||||
getApp().getHashRouter ().setFlag (trans->getID (), SF_SIGGOOD);
|
||||
}
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
bool didApply;
|
||||
TER r = mLedgerMaster->doTransaction (trans->getSTransaction (),
|
||||
bAdmin ? (tapOPEN_LEDGER | tapNO_CHECK_SIGN | tapADMIN) : (tapOPEN_LEDGER | tapNO_CHECK_SIGN), didApply);
|
||||
trans->setResult (r);
|
||||
{
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
if (isTemMalformed (r)) // malformed, cache bad
|
||||
getApp().getHashRouter ().setFlag (trans->getID (), SF_BAD);
|
||||
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||
// getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
|
||||
bool didApply;
|
||||
TER r = mLedgerMaster->doTransaction (trans->getSTransaction (),
|
||||
bAdmin ? (tapOPEN_LEDGER | tapNO_CHECK_SIGN | tapADMIN) : (tapOPEN_LEDGER | tapNO_CHECK_SIGN), didApply);
|
||||
trans->setResult (r);
|
||||
|
||||
if (isTemMalformed (r)) // malformed, cache bad
|
||||
getApp().getHashRouter ().setFlag (trans->getID (), SF_BAD);
|
||||
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
|
||||
// getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
|
||||
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
if (r != tesSUCCESS)
|
||||
{
|
||||
std::string token, human;
|
||||
CondLog (transResultInfo (r, token, human), lsINFO, NetworkOPs) << "TransactionResult: " << token << ": " << human;
|
||||
}
|
||||
if (r != tesSUCCESS)
|
||||
{
|
||||
std::string token, human;
|
||||
CondLog (transResultInfo (r, token, human), lsINFO, NetworkOPs) << "TransactionResult: " << token << ": " << human;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (callback)
|
||||
callback (trans, r);
|
||||
if (callback)
|
||||
callback (trans, r);
|
||||
|
||||
if (r == tefFAILURE)
|
||||
throw Fault (IO_ERROR);
|
||||
if (r == tefFAILURE)
|
||||
throw Fault (IO_ERROR);
|
||||
|
||||
if (r == tesSUCCESS)
|
||||
{
|
||||
WriteLog (lsINFO, NetworkOPs) << "Transaction is now included in open ledger";
|
||||
trans->setStatus (INCLUDED);
|
||||
getApp().getMasterTransaction ().canonicalize (trans);
|
||||
}
|
||||
else if (r == tefPAST_SEQ)
|
||||
{
|
||||
// duplicate or conflict
|
||||
WriteLog (lsINFO, NetworkOPs) << "Transaction is obsolete";
|
||||
trans->setStatus (OBSOLETE);
|
||||
}
|
||||
else if (isTerRetry (r))
|
||||
{
|
||||
if (!bFailHard)
|
||||
if (r == tesSUCCESS)
|
||||
{
|
||||
// transaction should be held
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "Transaction should be held: " << r;
|
||||
trans->setStatus (HELD);
|
||||
getApp().getMasterTransaction ().canonicalize (trans);
|
||||
mLedgerMaster->addHeldTransaction (trans);
|
||||
WriteLog (lsINFO, NetworkOPs) << "Transaction is now included in open ledger";
|
||||
trans->setStatus (INCLUDED);
|
||||
getApp().getMasterTransaction ().canonicalize (trans);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "Status other than success " << r;
|
||||
trans->setStatus (INVALID);
|
||||
}
|
||||
|
||||
if (didApply || ((mMode != omFULL) && !bFailHard))
|
||||
{
|
||||
std::set<uint64> peers;
|
||||
|
||||
if (getApp().getHashRouter ().swapSet (trans->getID (), peers, SF_RELAYED))
|
||||
else if (r == tefPAST_SEQ)
|
||||
{
|
||||
protocol::TMTransaction tx;
|
||||
Serializer s;
|
||||
trans->getSTransaction ()->add (s);
|
||||
tx.set_rawtransaction (&s.getData ().front (), s.getLength ());
|
||||
tx.set_status (protocol::tsCURRENT);
|
||||
tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it
|
||||
// duplicate or conflict
|
||||
WriteLog (lsINFO, NetworkOPs) << "Transaction is obsolete";
|
||||
trans->setStatus (OBSOLETE);
|
||||
}
|
||||
else if (isTerRetry (r))
|
||||
{
|
||||
if (!bFailHard)
|
||||
{
|
||||
// transaction should be held
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "Transaction should be held: " << r;
|
||||
trans->setStatus (HELD);
|
||||
getApp().getMasterTransaction ().canonicalize (trans);
|
||||
mLedgerMaster->addHeldTransaction (trans);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsDEBUG, NetworkOPs) << "Status other than success " << r;
|
||||
trans->setStatus (INVALID);
|
||||
}
|
||||
|
||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tx, protocol::mtTRANSACTION);
|
||||
getApp().getPeers ().relayMessageBut (peers, packet);
|
||||
if (didApply || ((mMode != omFULL) && !bFailHard))
|
||||
{
|
||||
std::set<uint64> peers;
|
||||
|
||||
if (getApp().getHashRouter ().swapSet (trans->getID (), peers, SF_RELAYED))
|
||||
{
|
||||
protocol::TMTransaction tx;
|
||||
Serializer s;
|
||||
trans->getSTransaction ()->add (s);
|
||||
tx.set_rawtransaction (&s.getData ().front (), s.getLength ());
|
||||
tx.set_status (protocol::tsCURRENT);
|
||||
tx.set_receivetimestamp (getNetworkTimeNC ()); // FIXME: This should be when we received it
|
||||
|
||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tx, protocol::mtTRANSACTION);
|
||||
getApp().getPeers ().relayMessageBut (peers, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -955,49 +963,53 @@ uint256 NetworkOPs::getConsensusLCL ()
|
||||
void NetworkOPs::processTrustedProposal (LedgerProposal::pointer proposal,
|
||||
boost::shared_ptr<protocol::TMProposeSet> set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
|
||||
bool relay = true;
|
||||
|
||||
if (!haveConsensusObject ())
|
||||
{
|
||||
WriteLog (lsINFO, NetworkOPs) << "Received proposal outside consensus window";
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
if (mMode == omFULL)
|
||||
relay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
storeProposal (proposal, nodePublic);
|
||||
bool relay = true;
|
||||
|
||||
uint256 consensusLCL = mConsensus->getLCL ();
|
||||
|
||||
if (!set->has_previousledger () && (checkLedger != consensusLCL))
|
||||
if (!haveConsensusObject ())
|
||||
{
|
||||
WriteLog (lsWARNING, NetworkOPs) << "Have to re-check proposal signature due to consensus view change";
|
||||
assert (proposal->hasSignature ());
|
||||
proposal->setPrevLedger (consensusLCL);
|
||||
WriteLog (lsINFO, NetworkOPs) << "Received proposal outside consensus window";
|
||||
|
||||
if (proposal->checkSign ())
|
||||
sigGood = true;
|
||||
if (mMode == omFULL)
|
||||
relay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
storeProposal (proposal, nodePublic);
|
||||
|
||||
uint256 consensusLCL = mConsensus->getLCL ();
|
||||
|
||||
if (!set->has_previousledger () && (checkLedger != consensusLCL))
|
||||
{
|
||||
WriteLog (lsWARNING, NetworkOPs) << "Have to re-check proposal signature due to consensus view change";
|
||||
assert (proposal->hasSignature ());
|
||||
proposal->setPrevLedger (consensusLCL);
|
||||
|
||||
if (proposal->checkSign ())
|
||||
sigGood = true;
|
||||
}
|
||||
|
||||
if (sigGood && (consensusLCL == proposal->getPrevLedger ()))
|
||||
{
|
||||
relay = mConsensus->peerPosition (proposal);
|
||||
WriteLog (lsTRACE, NetworkOPs) << "Proposal processing finished, relay=" << relay;
|
||||
}
|
||||
}
|
||||
|
||||
if (sigGood && (consensusLCL == proposal->getPrevLedger ()))
|
||||
if (relay)
|
||||
{
|
||||
relay = mConsensus->peerPosition (proposal);
|
||||
WriteLog (lsTRACE, NetworkOPs) << "Proposal processing finished, relay=" << relay;
|
||||
std::set<uint64> peers;
|
||||
getApp().getHashRouter ().swapSet (proposal->getHashRouter (), peers, SF_RELAYED);
|
||||
PackedMessage::pointer message = boost::make_shared<PackedMessage> (*set, protocol::mtPROPOSE_LEDGER);
|
||||
getApp().getPeers ().relayMessageBut (peers, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, NetworkOPs) << "Not relaying trusted proposal";
|
||||
}
|
||||
}
|
||||
|
||||
if (relay)
|
||||
{
|
||||
std::set<uint64> peers;
|
||||
getApp().getHashRouter ().swapSet (proposal->getHashRouter (), peers, SF_RELAYED);
|
||||
PackedMessage::pointer message = boost::make_shared<PackedMessage> (*set, protocol::mtPROPOSE_LEDGER);
|
||||
getApp().getPeers ().relayMessageBut (peers, message);
|
||||
}
|
||||
else
|
||||
WriteLog (lsINFO, NetworkOPs) << "Not relaying trusted proposal";
|
||||
}
|
||||
|
||||
SHAMap::pointer NetworkOPs::getTXMap (uint256 const& hash)
|
||||
@@ -1039,8 +1051,10 @@ SHAMapAddNode NetworkOPs::gotTXData (const boost::shared_ptr<Peer>& peer, uint25
|
||||
{
|
||||
|
||||
boost::shared_ptr<LedgerConsensus> consensus;
|
||||
|
||||
{
|
||||
ScopedLock mlh(getApp().getMasterLock());
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
consensus = mConsensus;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ RPCHandler::RPCHandler (NetworkOPs* netOps, InfoSub::pointer infoSub) : mNetOps
|
||||
;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool bFailHard, ScopedLock& mlh)
|
||||
Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool bFailHard, Application::ScopedLockType& mlh)
|
||||
{
|
||||
if (getApp().getFeeTrack().isLoadedCluster() && (mRole != ADMIN))
|
||||
return rpcError(rpcTOO_BUSY);
|
||||
@@ -595,7 +595,7 @@ Json::Value RPCHandler::accountFromString (Ledger::ref lrLedger, RippleAddress&
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -640,7 +640,7 @@ Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, S
|
||||
// port: <number>
|
||||
// }
|
||||
// XXX Might allow domain for manual connections.
|
||||
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (theConfig.RUN_STANDALONE)
|
||||
return "cannot connect in standalone mode";
|
||||
@@ -661,7 +661,7 @@ Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Scope
|
||||
// {
|
||||
// key: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("key"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -687,7 +687,7 @@ Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Sc
|
||||
// {
|
||||
// key: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("key"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -711,7 +711,7 @@ Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, Sco
|
||||
// key: <string>
|
||||
// value: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataStore (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doDataStore (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("key")
|
||||
|| !params.isMember ("value"))
|
||||
@@ -772,7 +772,7 @@ Json::Value RPCHandler::doNicknameInfo (Json::Value params)
|
||||
// 'account_index' : <index> // optional
|
||||
// }
|
||||
// XXX This would be better if it took the ledger.
|
||||
Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("account") && !params.isMember ("ident"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -797,7 +797,7 @@ Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, Sco
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
@@ -808,7 +808,7 @@ Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, ScopedLock& Ma
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
return Json::Value (Json::objectValue);
|
||||
}
|
||||
@@ -818,7 +818,7 @@ Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, ScopedLock& Mas
|
||||
// issuer is the offering account
|
||||
// --> submit: 'submit|true|false': defaults to false
|
||||
// Prior to running allow each to have a credit line of what they will be getting from the other account.
|
||||
Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
/* need to fix now that sharedOfferCreate is gone
|
||||
int iArgs = params.size();
|
||||
@@ -910,9 +910,9 @@ Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Scope
|
||||
// difficulty: <number> // optional
|
||||
// secret: <secret> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
// XXX: Add ability to create proof with arbitrary time
|
||||
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
@@ -955,9 +955,9 @@ Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, S
|
||||
// {
|
||||
// token: <token>
|
||||
// }
|
||||
Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -985,9 +985,9 @@ Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Sc
|
||||
// difficulty: <number> // optional
|
||||
// secret: <secret> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
// XXX Add ability to check proof against arbitrary time
|
||||
|
||||
Json::Value jvResult;
|
||||
@@ -1055,7 +1055,7 @@ Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, S
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -1067,7 +1067,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType,
|
||||
|
||||
if (lpLedger->isImmutable ())
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
bUnlocked = true;
|
||||
}
|
||||
|
||||
@@ -1140,7 +1140,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType,
|
||||
}
|
||||
|
||||
if (!bUnlocked)
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1168,7 +1168,7 @@ static void offerAdder (Json::Value& jvLines, SLE::ref offer)
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -1180,7 +1180,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
|
||||
|
||||
if (lpLedger->isImmutable ())
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
bUnlocked = true;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1212,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
|
||||
lpLedger->visitAccountItems (raAccount.getAccountID (), BIND_TYPE (&offerAdder, boost::ref (jvsOffers), P_1));
|
||||
|
||||
if (!bUnlocked)
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
@@ -1227,7 +1227,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
|
||||
// "limit" : integer, // Optional.
|
||||
// "proof" : boolean // Defaults to false.
|
||||
// }
|
||||
Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (getApp().getJobQueue ().getJobCountGE (jtCLIENT) > 200)
|
||||
{
|
||||
@@ -1241,7 +1241,7 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Sc
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable ())
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
if (!params.isMember ("taker_pays") || !params.isMember ("taker_gets") || !params["taker_pays"].isObject () || !params["taker_gets"].isObject ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -1328,9 +1328,9 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Sc
|
||||
// {
|
||||
// random: <uint256>
|
||||
// }
|
||||
Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
uint256 uRandom;
|
||||
|
||||
try
|
||||
@@ -1349,7 +1349,7 @@ Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Scoped
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("subcommand") || !params["subcommand"].isString ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -1404,7 +1404,7 @@ Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Scop
|
||||
// - Allows clients to verify path exists.
|
||||
// - Return canonicalized path.
|
||||
// - From a trusted server, allows clients to use path without manipulation.
|
||||
Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
|
||||
@@ -1487,7 +1487,7 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
|
||||
*loadType = LT_RPCBurden;
|
||||
Ledger::pointer lSnapShot = boost::make_shared<Ledger> (boost::ref (*lpLedger), false);
|
||||
|
||||
MasterLockHolder.unlock (); // As long as we have a locked copy of the ledger, we can unlock.
|
||||
masterLockHolder.unlock (); // As long as we have a locked copy of the ledger, we can unlock.
|
||||
|
||||
// Fill in currencies destination will accept
|
||||
Json::Value jvDestCur (Json::arrayValue);
|
||||
@@ -1636,23 +1636,23 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
|
||||
// tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
*loadType = LT_RPCBurden;
|
||||
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
|
||||
return transactionSign (params, false, bFailHard, MasterLockHolder);
|
||||
return transactionSign (params, false, bFailHard, masterLockHolder);
|
||||
}
|
||||
|
||||
// {
|
||||
// tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("tx_blob"))
|
||||
{
|
||||
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
|
||||
return transactionSign (params, true, bFailHard, MasterLockHolder);
|
||||
return transactionSign (params, true, bFailHard, masterLockHolder);
|
||||
}
|
||||
|
||||
Json::Value jvResult;
|
||||
@@ -1710,7 +1710,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Scoped
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1740,7 +1740,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Scoped
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
@@ -1749,9 +1749,9 @@ Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Scoped
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
@@ -1766,7 +1766,7 @@ Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, S
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
@@ -1775,7 +1775,7 @@ Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, ScopedLoc
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
@@ -1787,9 +1787,9 @@ Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, ScopedLo
|
||||
// {
|
||||
// start: <index>
|
||||
// }
|
||||
Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
if (!params.isMember ("start"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -1824,7 +1824,7 @@ Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, Sco
|
||||
// {
|
||||
// transaction: <hex>
|
||||
// }
|
||||
Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("transaction"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -1890,7 +1890,7 @@ Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, ScopedLock
|
||||
return rpcError (rpcNOT_IMPL);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -1903,7 +1903,7 @@ Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, ScopedL
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -1917,7 +1917,7 @@ Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Scoped
|
||||
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
|
||||
// full: true | false // optional, defaults to false.
|
||||
// }
|
||||
Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("ledger") && !params.isMember ("ledger_hash") && !params.isMember ("ledger_index"))
|
||||
{
|
||||
@@ -1939,7 +1939,7 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Scoped
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable ())
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
bool bFull = params.isMember ("full") && params["full"].asBool ();
|
||||
bool bTransactions = params.isMember ("transactions") && params["transactions"].asBool ();
|
||||
@@ -1966,7 +1966,7 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Scoped
|
||||
// offset: integer, // optional, defaults to 0
|
||||
// limit: integer // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
RippleAddress raAccount;
|
||||
uint32 offset = params.isMember ("offset") ? params["offset"].asUInt () : 0;
|
||||
@@ -2035,7 +2035,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
||||
try
|
||||
{
|
||||
#endif
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
@@ -2111,7 +2111,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
|
||||
// }
|
||||
//
|
||||
// This command requires admin access because it makes no sense to ask an untrusted server for this.
|
||||
Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
RippleAddress raSeed;
|
||||
Json::Value obj (Json::objectValue);
|
||||
@@ -2137,7 +2137,7 @@ Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadTy
|
||||
// {
|
||||
// secret: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
@@ -2208,7 +2208,7 @@ Json::Value RPCHandler::accounts (Ledger::ref lrLedger, const RippleAddress& naM
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -2251,7 +2251,7 @@ Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
return Log::rotateLog ();
|
||||
}
|
||||
@@ -2259,9 +2259,9 @@ Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, ScopedLock
|
||||
// {
|
||||
// passphrase: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
RippleAddress naSeed;
|
||||
RippleAddress naAccount;
|
||||
@@ -2291,7 +2291,7 @@ Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType,
|
||||
// {
|
||||
// secret: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
RippleAddress raSeed;
|
||||
bool bSecret = params.isMember ("secret");
|
||||
@@ -2330,7 +2330,7 @@ Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Sc
|
||||
// username: <string>,
|
||||
// password: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("username")
|
||||
|| !params.isMember ("password"))
|
||||
@@ -2368,7 +2368,7 @@ static void textTime (std::string& text, int& seconds, const char* unitName, int
|
||||
text += "s";
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, ScopedLock& mlh)
|
||||
Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh)
|
||||
{
|
||||
if (!params.isMember ("feature"))
|
||||
{
|
||||
@@ -2397,7 +2397,7 @@ Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Scope
|
||||
// {
|
||||
// min_count: <number> // optional, defaults to 10
|
||||
// }
|
||||
Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
int minCount = 10;
|
||||
|
||||
@@ -2449,7 +2449,7 @@ Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Sco
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
// log_level
|
||||
if (!params.isMember ("severity"))
|
||||
@@ -2502,7 +2502,7 @@ Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Scop
|
||||
// node: <domain>|<node_public>,
|
||||
// comment: <comment> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
std::string strNode = params.isMember ("node") ? params["node"].asString () : "";
|
||||
std::string strComment = params.isMember ("comment") ? params["comment"].asString () : "";
|
||||
@@ -2526,7 +2526,7 @@ Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Scoped
|
||||
// {
|
||||
// node: <domain>|<public_key>
|
||||
// }
|
||||
Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("node"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -2549,7 +2549,7 @@ Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, Sco
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
@@ -2559,7 +2559,7 @@ Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, ScopedLock&
|
||||
}
|
||||
|
||||
// Populate the UNL from a local validators.txt file.
|
||||
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (theConfig.VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (theConfig.VALIDATORS_FILE))
|
||||
{
|
||||
@@ -2571,7 +2571,7 @@ Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, ScopedLock&
|
||||
|
||||
|
||||
// Populate the UNL from ripple.com's validators.txt file.
|
||||
Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
getApp().getUNL ().nodeNetwork ();
|
||||
|
||||
@@ -2579,7 +2579,7 @@ Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Sc
|
||||
}
|
||||
|
||||
// unl_reset
|
||||
Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
getApp().getUNL ().nodeReset ();
|
||||
|
||||
@@ -2587,14 +2587,14 @@ Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Scop
|
||||
}
|
||||
|
||||
// unl_score
|
||||
Json::Value RPCHandler::doUnlScore (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnlScore (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
getApp().getUNL ().nodeScore ();
|
||||
|
||||
return "scoring requested";
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
if (!params.isMember ("text"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -2603,14 +2603,14 @@ Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, ScopedLoc
|
||||
|
||||
return "sms dispatched";
|
||||
}
|
||||
Json::Value RPCHandler::doStop (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doStop (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
getApp().stop ();
|
||||
|
||||
return SYSTEM_NAME " server stopping";
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -2633,7 +2633,7 @@ Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, ScopedL
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
// XXX In this case, not specify either ledger does not mean ledger current. It means any ledger.
|
||||
Json::Value RPCHandler::doTransactionEntry (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doTransactionEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -2802,7 +2802,7 @@ Json::Value RPCHandler::lookupLedger (Json::Value params, Ledger::pointer& lpLed
|
||||
// ledger_index : <ledger_index>
|
||||
// ...
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -2811,7 +2811,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, S
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable ())
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
uint256 uNodeIndex;
|
||||
bool bNodeBinary = false;
|
||||
@@ -3015,7 +3015,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, S
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerHeader (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doLedgerHeader (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = lookupLedger (params, lpLedger);
|
||||
@@ -3057,7 +3057,7 @@ boost::unordered_set<RippleAddress> RPCHandler::parseAccountIds (const Json::Val
|
||||
return usnaResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
@@ -3349,7 +3349,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, Sco
|
||||
}
|
||||
|
||||
// FIXME: This leaks RPCSub objects for JSON-RPC. Shouldn't matter for anyone sane.
|
||||
Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
@@ -3571,7 +3571,7 @@ Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
// Used for debug or special-purpose RPC commands
|
||||
if (!params.isMember ("internal_command"))
|
||||
@@ -3694,53 +3694,55 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
}
|
||||
|
||||
ScopedLock MasterLockHolder (getApp().getMasterLock ());
|
||||
{
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
if ((commandsA[i].iOptions & optNetwork) && (mNetOps->getOperatingMode () < NetworkOPs::omSYNCING))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Insufficient network mode for RPC: " << mNetOps->strOperatingMode ();
|
||||
|
||||
return rpcError (rpcNO_NETWORK);
|
||||
}
|
||||
|
||||
if (!theConfig.RUN_STANDALONE && (commandsA[i].iOptions & optCurrent) && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
|
||||
{
|
||||
return rpcError (rpcNO_CURRENT);
|
||||
}
|
||||
else if ((commandsA[i].iOptions & optClosed) && !mNetOps->getClosedLedger ())
|
||||
{
|
||||
return rpcError (rpcNO_CLOSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
if ((commandsA[i].iOptions & optNetwork) && (mNetOps->getOperatingMode () < NetworkOPs::omSYNCING))
|
||||
{
|
||||
Json::Value jvRaw = (this->* (commandsA[i].dfpFunc)) (params, loadType, MasterLockHolder);
|
||||
WriteLog (lsINFO, RPCHandler) << "Insufficient network mode for RPC: " << mNetOps->strOperatingMode ();
|
||||
|
||||
// Regularize result.
|
||||
if (jvRaw.isObject ())
|
||||
{
|
||||
// Got an object.
|
||||
return jvRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably got a string.
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult["message"] = jvRaw;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
return rpcError (rpcNO_NETWORK);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
||||
if (!theConfig.RUN_STANDALONE && (commandsA[i].iOptions & optCurrent) && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what ();
|
||||
return rpcError (rpcNO_CURRENT);
|
||||
}
|
||||
else if ((commandsA[i].iOptions & optClosed) && !mNetOps->getClosedLedger ())
|
||||
{
|
||||
return rpcError (rpcNO_CLOSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Json::Value jvRaw = (this->* (commandsA[i].dfpFunc)) (params, loadType, lock);
|
||||
|
||||
if (*loadType == LT_RPCReference)
|
||||
*loadType = LT_RPCException;
|
||||
// Regularize result.
|
||||
if (jvRaw.isObject ())
|
||||
{
|
||||
// Got an object.
|
||||
return jvRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably got a string.
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
return rpcError (rpcINTERNAL);
|
||||
jvResult["message"] = jvRaw;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what ();
|
||||
|
||||
if (*loadType == LT_RPCReference)
|
||||
*loadType = LT_RPCException;
|
||||
|
||||
return rpcError (rpcINTERNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
typedef Json::Value (RPCHandler::*doFuncPtr) (
|
||||
Json::Value params,
|
||||
LoadType* loadType,
|
||||
ScopedLock& MasterLockHolder);
|
||||
Application::ScopedLockType& MasterLockHolder);
|
||||
|
||||
// VFALCO TODO Document these and give the enumeration a label.
|
||||
enum
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
boost::unordered_set <RippleAddress> parseAccountIds (const Json::Value& jvArray);
|
||||
|
||||
Json::Value transactionSign (Json::Value jvRequest, bool bSubmit, bool bFailHard, ScopedLock& mlh);
|
||||
Json::Value transactionSign (Json::Value jvRequest, bool bSubmit, bool bFailHard, Application::ScopedLockType& mlh);
|
||||
|
||||
Json::Value lookupLedger (Json::Value jvRequest, Ledger::pointer& lpLedger);
|
||||
|
||||
@@ -89,71 +89,71 @@ private:
|
||||
const int iIndex,
|
||||
const bool bStrict);
|
||||
|
||||
Json::Value doAccountInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doAccountLines (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doAccountOffers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doAccountTransactions (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doBookOffers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doConnect (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doConsensusInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doFeature (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doFetchInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doGetCounts (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doInternal (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedger (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedgerAccept (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedgerClosed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedgerCurrent (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedgerEntry (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedgerHeader (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLogLevel (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLogRotate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doNicknameInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doOwnerInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doPathFind (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doPeers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doPing (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doProfile (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doProofCreate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doProofSolve (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doProofVerify (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doRandom (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doRipplePathFind (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doSMS (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doServerInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh); // for humans
|
||||
Json::Value doServerState (Json::Value params, LoadType* loadType, ScopedLock& mlh); // for machines
|
||||
Json::Value doSessionClose (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doSessionOpen (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doSign (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doStop (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doSubmit (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doSubscribe (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doTransactionEntry (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doTx (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doTxHistory (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlAdd (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlDelete (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlFetch (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlList (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlLoad (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlNetwork (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlReset (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnlScore (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doUnsubscribe (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doValidationCreate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doValidationSeed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletAccounts (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletLock (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletPropose (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletSeed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletUnlock (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doWalletVerify (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doAccountInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountLines (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountTransactions (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doBookOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doConsensusInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doFeature (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doFetchInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doGetCounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doInternal (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedger (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerAccept (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerClosed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerCurrent (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerHeader (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLogLevel (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLogRotate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doNicknameInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doOwnerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPeers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPing (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProfile (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofSolve (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doRandom (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doRipplePathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSMS (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doServerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh); // for humans
|
||||
Json::Value doServerState (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh); // for machines
|
||||
Json::Value doSessionClose (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSessionOpen (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSign (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doStop (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSubmit (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTransactionEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTxHistory (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlAdd (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlList (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlLoad (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlNetwork (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlReset (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlScore (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnsubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doValidationCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doValidationSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletAccounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletLock (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletPropose (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletUnlock (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
|
||||
#if ENABLE_INSECURE
|
||||
Json::Value doDataDelete (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doDataFetch (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doDataStore (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLogin (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doDataDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doDataFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doDataStore (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLogin (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,6 +16,7 @@ class ApplicationImp
|
||||
: public Application
|
||||
, public SharedSingleton <ApplicationImp>
|
||||
, public Validators::Listener
|
||||
, public NodeStore::Scheduler
|
||||
, LeakChecked <ApplicationImp>
|
||||
{
|
||||
public:
|
||||
@@ -43,17 +44,17 @@ public:
|
||||
#endif
|
||||
, mIOService ((theConfig.NODE_SIZE >= 2) ? 2 : 1)
|
||||
, mIOWork (mIOService)
|
||||
, mNetOps (&mLedgerMaster)
|
||||
, m_rpcServerHandler (mNetOps)
|
||||
, mNetOps (new NetworkOPs (&mLedgerMaster))
|
||||
, m_rpcServerHandler (*mNetOps)
|
||||
, mTempNodeCache ("NodeCache", 16384, 90)
|
||||
, m_nodeStore (
|
||||
theConfig.NODE_DB,
|
||||
theConfig.FASTNODE_DB,
|
||||
16384, 300)
|
||||
, mSLECache ("LedgerEntryCache", 4096, 120)
|
||||
, mSNTPClient (mAuxService)
|
||||
, mJobQueue (mIOService)
|
||||
// VFALCO New stuff
|
||||
, m_nodeStore (NodeStore::New (
|
||||
theConfig.nodeDatabase,
|
||||
theConfig.ephemeralNodeDatabase,
|
||||
*this))
|
||||
, m_validators (Validators::New (this))
|
||||
, mFeatures (IFeatures::New (2 * 7 * 24 * 60 * 60, 200)) // two weeks, 200/256
|
||||
, mFeeVote (IFeeVote::New (10, 50 * SYSTEM_CURRENCY_PARTS, 12.5 * SYSTEM_CURRENCY_PARTS))
|
||||
@@ -70,11 +71,6 @@ public:
|
||||
, mTxnDB (NULL)
|
||||
, mLedgerDB (NULL)
|
||||
, mWalletDB (NULL) // VFALCO NOTE are all these 'NULL' ctor params necessary?
|
||||
, mNetNodeDB (NULL)
|
||||
, mPathFindDB (NULL)
|
||||
, mHashNodeDB (NULL)
|
||||
, mHashNodeLDB (NULL)
|
||||
, mEphemeralLDB (NULL)
|
||||
, mPeerDoor (NULL)
|
||||
, mRPCDoor (NULL)
|
||||
, mWSPublicDoor (NULL)
|
||||
@@ -88,89 +84,101 @@ public:
|
||||
|
||||
~ApplicationImp ()
|
||||
{
|
||||
mNetOps = nullptr;
|
||||
|
||||
// VFALCO TODO Wrap these in ScopedPointer
|
||||
delete mTxnDB;
|
||||
delete mLedgerDB;
|
||||
delete mWalletDB;
|
||||
delete mHashNodeDB;
|
||||
delete mNetNodeDB;
|
||||
delete mPathFindDB;
|
||||
delete mHashNodeLDB;
|
||||
|
||||
if (mEphemeralLDB != nullptr)
|
||||
delete mEphemeralLDB;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static void callScheduledTask (NodeStore::Scheduler::Task* task, Job&)
|
||||
{
|
||||
task->performScheduledTask ();
|
||||
}
|
||||
|
||||
void scheduleTask (NodeStore::Scheduler::Task* task)
|
||||
{
|
||||
getJobQueue ().addJob (
|
||||
jtWRITE,
|
||||
"NodeObject::store",
|
||||
BIND_TYPE (&ApplicationImp::callScheduledTask, task, P_1));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
LocalCredentials& getLocalCredentials ()
|
||||
{
|
||||
return m_localCredentials ;
|
||||
}
|
||||
|
||||
|
||||
NetworkOPs& getOPs ()
|
||||
{
|
||||
return mNetOps;
|
||||
return *mNetOps;
|
||||
}
|
||||
|
||||
boost::asio::io_service& getIOService ()
|
||||
{
|
||||
return mIOService;
|
||||
}
|
||||
|
||||
|
||||
LedgerMaster& getLedgerMaster ()
|
||||
{
|
||||
return mLedgerMaster;
|
||||
}
|
||||
|
||||
|
||||
InboundLedgers& getInboundLedgers ()
|
||||
{
|
||||
return m_inboundLedgers;
|
||||
}
|
||||
|
||||
|
||||
TransactionMaster& getMasterTransaction ()
|
||||
{
|
||||
return mMasterTransaction;
|
||||
}
|
||||
|
||||
|
||||
NodeCache& getTempNodeCache ()
|
||||
{
|
||||
return mTempNodeCache;
|
||||
}
|
||||
|
||||
|
||||
NodeStore& getNodeStore ()
|
||||
{
|
||||
return m_nodeStore;
|
||||
return *m_nodeStore;
|
||||
}
|
||||
|
||||
|
||||
JobQueue& getJobQueue ()
|
||||
{
|
||||
return mJobQueue;
|
||||
}
|
||||
|
||||
boost::recursive_mutex& getMasterLock ()
|
||||
|
||||
MasterLockType& getMasterLock ()
|
||||
{
|
||||
return mMasterLock;
|
||||
}
|
||||
|
||||
|
||||
ILoadManager& getLoadManager ()
|
||||
{
|
||||
return *m_loadManager;
|
||||
}
|
||||
|
||||
|
||||
TXQueue& getTxnQueue ()
|
||||
{
|
||||
return mTxnQueue;
|
||||
}
|
||||
|
||||
|
||||
PeerDoor& getPeerDoor ()
|
||||
{
|
||||
return *mPeerDoor;
|
||||
}
|
||||
|
||||
|
||||
OrderBookDB& getOrderBookDB ()
|
||||
{
|
||||
return mOrderBookDB;
|
||||
}
|
||||
|
||||
|
||||
SLECache& getSLECache ()
|
||||
{
|
||||
return mSLECache;
|
||||
@@ -185,37 +193,37 @@ public:
|
||||
{
|
||||
return *mFeatures;
|
||||
}
|
||||
|
||||
|
||||
ILoadFeeTrack& getFeeTrack ()
|
||||
{
|
||||
return *mFeeTrack;
|
||||
}
|
||||
|
||||
|
||||
IFeeVote& getFeeVote ()
|
||||
{
|
||||
return *mFeeVote;
|
||||
}
|
||||
|
||||
|
||||
IHashRouter& getHashRouter ()
|
||||
{
|
||||
return *mHashRouter;
|
||||
}
|
||||
|
||||
|
||||
IValidations& getValidations ()
|
||||
{
|
||||
return *mValidations;
|
||||
}
|
||||
|
||||
|
||||
UniqueNodeList& getUNL ()
|
||||
{
|
||||
return *mUNL;
|
||||
}
|
||||
|
||||
|
||||
IProofOfWorkFactory& getProofOfWorkFactory ()
|
||||
{
|
||||
return *mProofOfWorkFactory;
|
||||
}
|
||||
|
||||
|
||||
IPeers& getPeers ()
|
||||
{
|
||||
return *mPeers;
|
||||
@@ -247,27 +255,6 @@ public:
|
||||
{
|
||||
return mWalletDB;
|
||||
}
|
||||
DatabaseCon* getNetNodeDB ()
|
||||
{
|
||||
return mNetNodeDB;
|
||||
}
|
||||
DatabaseCon* getPathFindDB ()
|
||||
{
|
||||
return mPathFindDB;
|
||||
}
|
||||
DatabaseCon* getHashNodeDB ()
|
||||
{
|
||||
return mHashNodeDB;
|
||||
}
|
||||
|
||||
leveldb::DB* getHashNodeLDB ()
|
||||
{
|
||||
return mHashNodeLDB;
|
||||
}
|
||||
leveldb::DB* getEphemeralLDB ()
|
||||
{
|
||||
return mEphemeralLDB;
|
||||
}
|
||||
|
||||
bool isShutdown ()
|
||||
{
|
||||
@@ -293,16 +280,15 @@ private:
|
||||
//
|
||||
boost::asio::io_service::work mIOWork;
|
||||
|
||||
boost::recursive_mutex mMasterLock;
|
||||
MasterLockType mMasterLock;
|
||||
|
||||
LocalCredentials m_localCredentials;
|
||||
LedgerMaster mLedgerMaster;
|
||||
InboundLedgers m_inboundLedgers;
|
||||
TransactionMaster mMasterTransaction;
|
||||
NetworkOPs mNetOps;
|
||||
ScopedPointer <NetworkOPs> mNetOps;
|
||||
RPCServerHandler m_rpcServerHandler;
|
||||
NodeCache mTempNodeCache;
|
||||
NodeStore m_nodeStore;
|
||||
SLECache mSLECache;
|
||||
SNTPClient mSNTPClient;
|
||||
JobQueue mJobQueue;
|
||||
@@ -310,29 +296,23 @@ private:
|
||||
OrderBookDB mOrderBookDB;
|
||||
|
||||
// VFALCO Clean stuff
|
||||
beast::ScopedPointer <Validators> m_validators;
|
||||
beast::ScopedPointer <IFeatures> mFeatures;
|
||||
beast::ScopedPointer <IFeeVote> mFeeVote;
|
||||
beast::ScopedPointer <ILoadFeeTrack> mFeeTrack;
|
||||
beast::ScopedPointer <IHashRouter> mHashRouter;
|
||||
beast::ScopedPointer <IValidations> mValidations;
|
||||
beast::ScopedPointer <UniqueNodeList> mUNL;
|
||||
beast::ScopedPointer <IProofOfWorkFactory> mProofOfWorkFactory;
|
||||
beast::ScopedPointer <IPeers> mPeers;
|
||||
beast::ScopedPointer <ILoadManager> m_loadManager;
|
||||
ScopedPointer <NodeStore> m_nodeStore;
|
||||
ScopedPointer <Validators> m_validators;
|
||||
ScopedPointer <IFeatures> mFeatures;
|
||||
ScopedPointer <IFeeVote> mFeeVote;
|
||||
ScopedPointer <ILoadFeeTrack> mFeeTrack;
|
||||
ScopedPointer <IHashRouter> mHashRouter;
|
||||
ScopedPointer <IValidations> mValidations;
|
||||
ScopedPointer <UniqueNodeList> mUNL;
|
||||
ScopedPointer <IProofOfWorkFactory> mProofOfWorkFactory;
|
||||
ScopedPointer <IPeers> mPeers;
|
||||
ScopedPointer <ILoadManager> m_loadManager;
|
||||
// VFALCO End Clean stuff
|
||||
|
||||
DatabaseCon* mRpcDB;
|
||||
DatabaseCon* mTxnDB;
|
||||
DatabaseCon* mLedgerDB;
|
||||
DatabaseCon* mWalletDB;
|
||||
DatabaseCon* mNetNodeDB;
|
||||
DatabaseCon* mPathFindDB;
|
||||
DatabaseCon* mHashNodeDB;
|
||||
|
||||
// VFALCO TODO Wrap this in an interface
|
||||
leveldb::DB* mHashNodeLDB;
|
||||
leveldb::DB* mEphemeralLDB;
|
||||
|
||||
ScopedPointer <PeerDoor> mPeerDoor;
|
||||
ScopedPointer <RPCDoor> mRPCDoor;
|
||||
@@ -353,19 +333,11 @@ void ApplicationImp::stop ()
|
||||
StopSustain ();
|
||||
mShutdown = true;
|
||||
mIOService.stop ();
|
||||
// VFALCO TODO We shouldn't have to explicitly call this function.
|
||||
// The NodeStore destructor should take care of it.
|
||||
m_nodeStore.waitWrite ();
|
||||
m_nodeStore = nullptr;
|
||||
mValidations->flush ();
|
||||
mAuxService.stop ();
|
||||
mJobQueue.shutdown ();
|
||||
|
||||
delete mHashNodeLDB;
|
||||
mHashNodeLDB = NULL;
|
||||
|
||||
delete mEphemeralLDB;
|
||||
mEphemeralLDB = NULL;
|
||||
|
||||
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped ();
|
||||
mShutdown = false;
|
||||
}
|
||||
@@ -427,7 +399,7 @@ void ApplicationImp::setup ()
|
||||
|
||||
if (!theConfig.DEBUG_LOGFILE.empty ())
|
||||
{
|
||||
// Let BEAST_DEBUG messages go to the file but only WARNING or higher to regular output (unless verbose)
|
||||
// Let debug messages go to the file but only WARNING or higher to regular output (unless verbose)
|
||||
Log::setLogFile (theConfig.DEBUG_LOGFILE);
|
||||
|
||||
if (Log::getMinSeverity () > lsDEBUG)
|
||||
@@ -445,16 +417,11 @@ void ApplicationImp::setup ()
|
||||
boost::thread t1 (BIND_TYPE (&InitDB, &mRpcDB, "rpc.db", RpcDBInit, RpcDBCount));
|
||||
boost::thread t2 (BIND_TYPE (&InitDB, &mTxnDB, "transaction.db", TxnDBInit, TxnDBCount));
|
||||
boost::thread t3 (BIND_TYPE (&InitDB, &mLedgerDB, "ledger.db", LedgerDBInit, LedgerDBCount));
|
||||
boost::thread t4 (BIND_TYPE (&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount));
|
||||
t1.join ();
|
||||
t2.join ();
|
||||
t3.join ();
|
||||
|
||||
boost::thread t4 (BIND_TYPE (&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount));
|
||||
boost::thread t6 (BIND_TYPE (&InitDB, &mNetNodeDB, "netnode.db", NetNodeDBInit, NetNodeDBCount));
|
||||
boost::thread t7 (BIND_TYPE (&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount));
|
||||
t4.join ();
|
||||
t6.join ();
|
||||
t7.join ();
|
||||
|
||||
leveldb::Options options;
|
||||
options.create_if_missing = true;
|
||||
@@ -493,7 +460,7 @@ void ApplicationImp::setup ()
|
||||
{
|
||||
// This should probably become the default once we have a stable network
|
||||
if (!theConfig.RUN_STANDALONE)
|
||||
mNetOps.needNetworkLedger ();
|
||||
mNetOps->needNetworkLedger ();
|
||||
|
||||
startNewLedger ();
|
||||
}
|
||||
@@ -515,7 +482,7 @@ void ApplicationImp::setup ()
|
||||
getUNL ().nodeBootstrap ();
|
||||
|
||||
mValidations->tune (theConfig.getSize (siValidationsSize), theConfig.getSize (siValidationsAge));
|
||||
m_nodeStore.tune (theConfig.getSize (siNodeCacheSize), theConfig.getSize (siNodeCacheAge));
|
||||
m_nodeStore->tune (theConfig.getSize (siNodeCacheSize), theConfig.getSize (siNodeCacheAge));
|
||||
mLedgerMaster.tune (theConfig.getSize (siLedgerSize), theConfig.getSize (siLedgerAge));
|
||||
mSLECache.setTargetSize (theConfig.getSize (siSLECacheSize));
|
||||
mSLECache.setTargetAge (theConfig.getSize (siSLECacheAge));
|
||||
@@ -624,13 +591,13 @@ void ApplicationImp::setup ()
|
||||
{
|
||||
WriteLog (lsWARNING, Application) << "Running in standalone mode";
|
||||
|
||||
mNetOps.setStandAlone ();
|
||||
mNetOps->setStandAlone ();
|
||||
}
|
||||
else
|
||||
{
|
||||
// VFALCO NOTE the state timer resets the deadlock detector.
|
||||
//
|
||||
mNetOps.setStateTimer ();
|
||||
mNetOps->setStateTimer ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +613,7 @@ void ApplicationImp::run ()
|
||||
// VFALCO NOTE This seems unnecessary. If we properly refactor the load
|
||||
// manager then the deadlock detector can just always be "armed"
|
||||
//
|
||||
getApp().getLoadManager ().activateDeadlockDetector ();
|
||||
getApp().getLoadManager ().activateDeadlockDetector ();
|
||||
}
|
||||
|
||||
mIOService.run (); // This blocks
|
||||
@@ -697,7 +664,7 @@ void ApplicationImp::doSweep(Job& j)
|
||||
//
|
||||
|
||||
mMasterTransaction.sweep ();
|
||||
m_nodeStore.sweep ();
|
||||
m_nodeStore->sweep ();
|
||||
mLedgerMaster.sweep ();
|
||||
mTempNodeCache.sweep ();
|
||||
mValidations->sweep ();
|
||||
@@ -705,8 +672,8 @@ void ApplicationImp::doSweep(Job& j)
|
||||
mSLECache.sweep ();
|
||||
AcceptedLedger::sweep (); // VFALCO NOTE AcceptedLedger is/has a singleton?
|
||||
SHAMap::sweep (); // VFALCO NOTE SHAMap is/has a singleton?
|
||||
mNetOps.sweepFetchPack ();
|
||||
|
||||
mNetOps->sweepFetchPack ();
|
||||
// VFALCO NOTE does the call to sweep() happen on another thread?
|
||||
mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval)));
|
||||
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
|
||||
}
|
||||
@@ -737,7 +704,7 @@ void ApplicationImp::startNewLedger ()
|
||||
secondLedger->setAccepted ();
|
||||
mLedgerMaster.pushLedger (secondLedger, boost::make_shared<Ledger> (true, boost::ref (*secondLedger)), false);
|
||||
assert (!!secondLedger->getAccountState (rootAddress));
|
||||
mNetOps.setLastCloseTime (secondLedger->getCloseTimeNC ());
|
||||
mNetOps->setLastCloseTime (secondLedger->getCloseTimeNC ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,7 +772,7 @@ bool ApplicationImp::loadOldLedger (const std::string& l, bool bReplay)
|
||||
Ledger::pointer openLedger = boost::make_shared<Ledger> (false, boost::ref (*loadLedger));
|
||||
mLedgerMaster.switchLedgers (loadLedger, openLedger);
|
||||
mLedgerMaster.forceValid(loadLedger);
|
||||
mNetOps.setLastCloseTime (loadLedger->getCloseTimeNC ());
|
||||
mNetOps->setLastCloseTime (loadLedger->getCloseTimeNC ());
|
||||
|
||||
if (bReplay)
|
||||
{ // inject transaction from replayLedger into consensus set
|
||||
@@ -988,15 +955,9 @@ static void addTxnSeqField ()
|
||||
|
||||
void ApplicationImp::updateTables ()
|
||||
{
|
||||
if (theConfig.NODE_DB.empty ())
|
||||
if (theConfig.nodeDatabase.size () <= 0)
|
||||
{
|
||||
Log (lsFATAL) << "The NODE_DB configuration setting MUST be set";
|
||||
StopSustain ();
|
||||
exit (1);
|
||||
}
|
||||
else if (theConfig.NODE_DB == "LevelDB" || theConfig.NODE_DB == "SQLite")
|
||||
{
|
||||
Log (lsFATAL) << "The NODE_DB setting has been updated, your value is out of date";
|
||||
Log (lsFATAL) << "The [node_db] configuration setting has been updated and must be set";
|
||||
StopSustain ();
|
||||
exit (1);
|
||||
}
|
||||
@@ -1013,8 +974,16 @@ void ApplicationImp::updateTables ()
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!theConfig.DB_IMPORT.empty())
|
||||
getApp().getNodeStore().import(theConfig.DB_IMPORT);
|
||||
if (theConfig.importNodeDatabase.size () > 0)
|
||||
{
|
||||
ScopedPointer <NodeStore> source (NodeStore::New (theConfig.importNodeDatabase));
|
||||
|
||||
WriteLog (lsWARNING, NodeObject) <<
|
||||
"Node import from '" << source->getName () << "' to '"
|
||||
<< getApp().getNodeStore().getName () << "'.";
|
||||
|
||||
getApp().getNodeStore().import (*source);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -38,8 +38,6 @@ typedef TaggedCache <uint256, SerializedLedgerEntry, UptimeTimerAdapter> SLECach
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
virtual ~Application () { }
|
||||
|
||||
/* VFALCO NOTE
|
||||
|
||||
The master lock protects:
|
||||
@@ -51,7 +49,110 @@ public:
|
||||
|
||||
other things
|
||||
*/
|
||||
virtual boost::recursive_mutex& getMasterLock () = 0;
|
||||
#if 1
|
||||
class ScopedLockType;
|
||||
|
||||
class MasterLockType
|
||||
{
|
||||
public:
|
||||
MasterLockType ()
|
||||
: m_fileName ("")
|
||||
, m_lineNumber (0)
|
||||
{
|
||||
}
|
||||
|
||||
// Note that these are not exactly thread safe.
|
||||
|
||||
char const* getFileName () const noexcept
|
||||
{
|
||||
return m_fileName.get ();
|
||||
}
|
||||
|
||||
int getLineNumber () const noexcept
|
||||
{
|
||||
return m_lineNumber.get ();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ScopedLockType;
|
||||
|
||||
void setOwner (char const* fileName, int lineNumber)
|
||||
{
|
||||
m_fileName.set (fileName);
|
||||
m_lineNumber.set (lineNumber);
|
||||
}
|
||||
|
||||
void resetOwner ()
|
||||
{
|
||||
m_fileName.set ("");
|
||||
m_lineNumber.set (0);
|
||||
}
|
||||
|
||||
boost::recursive_mutex m_mutex;
|
||||
Atomic <char const*> m_fileName;
|
||||
Atomic <int> m_lineNumber;
|
||||
};
|
||||
|
||||
class ScopedLockType
|
||||
{
|
||||
public:
|
||||
explicit ScopedLockType (MasterLockType& mutex,
|
||||
char const* fileName,
|
||||
int lineNumber)
|
||||
: m_mutex (mutex)
|
||||
, m_lock (mutex.m_mutex)
|
||||
{
|
||||
mutex.setOwner (fileName, lineNumber);
|
||||
}
|
||||
|
||||
~ScopedLockType ()
|
||||
{
|
||||
if (m_lock.owns_lock ())
|
||||
m_mutex.resetOwner ();
|
||||
}
|
||||
|
||||
void unlock ()
|
||||
{
|
||||
if (m_lock.owns_lock ())
|
||||
m_mutex.resetOwner ();
|
||||
|
||||
m_lock.unlock ();
|
||||
}
|
||||
|
||||
private:
|
||||
MasterLockType& m_mutex;
|
||||
boost::recursive_mutex::scoped_lock m_lock;
|
||||
};
|
||||
|
||||
#else
|
||||
typedef boost::recursive_mutex MasterLockType;
|
||||
|
||||
typedef boost::recursive_mutex::scoped_lock ScopedLockType;
|
||||
|
||||
#endif
|
||||
|
||||
virtual MasterLockType& getMasterLock () = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
struct State
|
||||
{
|
||||
// Stuff in here is accessed concurrently and requires a WriteAccess
|
||||
};
|
||||
|
||||
typedef SharedData <State> SharedState;
|
||||
|
||||
SharedState& getSharedState () noexcept { return m_sharedState; }
|
||||
|
||||
SharedState const& getSharedState () const noexcept { return m_sharedState; }
|
||||
|
||||
private:
|
||||
SharedState m_sharedState;
|
||||
|
||||
public:
|
||||
virtual ~Application () { }
|
||||
|
||||
virtual boost::asio::io_service& getIOService () = 0;
|
||||
|
||||
@@ -89,15 +190,9 @@ public:
|
||||
It looks like this is used to store the unique node list.
|
||||
*/
|
||||
// VFALCO TODO Rename, document this
|
||||
// NOTE This will be replaced by class Validators
|
||||
//
|
||||
virtual DatabaseCon* getWalletDB () = 0;
|
||||
// VFALCO NOTE It looks like this isn't used...
|
||||
//virtual DatabaseCon* getNetNodeDB () = 0;
|
||||
// VFALCO NOTE It looks like this isn't used...
|
||||
//virtual DatabaseCon* getPathFindDB () = 0;
|
||||
virtual DatabaseCon* getHashNodeDB () = 0;
|
||||
|
||||
virtual leveldb::DB* getHashNodeLDB () = 0;
|
||||
virtual leveldb::DB* getEphemeralLDB () = 0;
|
||||
|
||||
virtual bool getSystemTimeOffset (int& offset) = 0;
|
||||
virtual bool isShutdown () = 0;
|
||||
|
||||
@@ -1179,155 +1179,157 @@ void LedgerConsensus::accept (SHAMap::ref set, LoadEvent::pointer)
|
||||
if (set->getHash ().isNonZero ()) // put our set where others can get it later
|
||||
getApp().getOPs ().takePosition (mPreviousLedger->getLedgerSeq (), set);
|
||||
|
||||
boost::recursive_mutex::scoped_lock masterLock (getApp().getMasterLock ());
|
||||
assert (set->getHash () == mOurPosition->getCurrentHash ());
|
||||
|
||||
getApp().getOPs ().peekStoredProposals ().clear (); // these are now obsolete
|
||||
|
||||
uint32 closeTime = roundCloseTime (mOurPosition->getCloseTime ());
|
||||
bool closeTimeCorrect = true;
|
||||
|
||||
if (closeTime == 0)
|
||||
{
|
||||
// we agreed to disagree
|
||||
closeTimeCorrect = false;
|
||||
closeTime = mPreviousLedger->getCloseTimeNC () + 1;
|
||||
}
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: Prop=" << (mProposing ? "yes" : "no") << " val=" << (mValidating ? "yes" : "no") <<
|
||||
" corLCL=" << (mHaveCorrectLCL ? "yes" : "no") << " fail=" << (mConsensusFail ? "yes" : "no");
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->getLedgerSeq ();
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: TxSt = " << set->getHash () << ", close " << closeTime << (closeTimeCorrect ? "" : "X");
|
||||
assert (set->getHash () == mOurPosition->getCurrentHash ());
|
||||
|
||||
CanonicalTXSet failedTransactions (set->getHash ());
|
||||
getApp().getOPs ().peekStoredProposals ().clear (); // these are now obsolete
|
||||
|
||||
Ledger::pointer newLCL = boost::make_shared<Ledger> (false, boost::ref (*mPreviousLedger));
|
||||
uint32 closeTime = roundCloseTime (mOurPosition->getCloseTime ());
|
||||
bool closeTimeCorrect = true;
|
||||
|
||||
newLCL->peekTransactionMap ()->armDirty ();
|
||||
newLCL->peekAccountStateMap ()->armDirty ();
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Applying consensus set transactions to the last closed ledger";
|
||||
applyTransactions (set, newLCL, newLCL, failedTransactions, false);
|
||||
newLCL->updateSkipList ();
|
||||
newLCL->setClosed ();
|
||||
boost::shared_ptr<SHAMap::DirtyMap> acctNodes = newLCL->peekAccountStateMap ()->disarmDirty ();
|
||||
boost::shared_ptr<SHAMap::DirtyMap> txnNodes = newLCL->peekTransactionMap ()->disarmDirty ();
|
||||
|
||||
// write out dirty nodes (temporarily done here) Most come before setAccepted
|
||||
int fc;
|
||||
|
||||
while ((fc = SHAMap::flushDirty (*acctNodes, 256, hotACCOUNT_NODE, newLCL->getLedgerSeq ())) > 0)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty state nodes";
|
||||
}
|
||||
|
||||
while ((fc = SHAMap::flushDirty (*txnNodes, 256, hotTRANSACTION_NODE, newLCL->getLedgerSeq ())) > 0)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty transaction nodes";
|
||||
}
|
||||
|
||||
newLCL->setAccepted (closeTime, mCloseResolution, closeTimeCorrect);
|
||||
newLCL->updateHash ();
|
||||
newLCL->setImmutable ();
|
||||
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: NewL = " << newLCL->getHash () << ":" << newLCL->getLedgerSeq ();
|
||||
uint256 newLCLHash = newLCL->getHash ();
|
||||
|
||||
if (ShouldLog (lsTRACE, LedgerConsensus))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "newLCL";
|
||||
Json::Value p;
|
||||
newLCL->addJson (p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
|
||||
WriteLog (lsTRACE, LedgerConsensus) << p;
|
||||
}
|
||||
|
||||
statusChange (protocol::neACCEPTED_LEDGER, *newLCL);
|
||||
|
||||
if (mValidating && !mConsensusFail)
|
||||
{
|
||||
uint256 signingHash;
|
||||
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
|
||||
(newLCLHash, getApp().getOPs ().getValidationTimeNC (), mValPublic, mProposing);
|
||||
v->setFieldU32 (sfLedgerSequence, newLCL->getLedgerSeq ());
|
||||
addLoad(v);
|
||||
|
||||
if (((newLCL->getLedgerSeq () + 1) % 256) == 0) // next ledger is flag ledger
|
||||
if (closeTime == 0)
|
||||
{
|
||||
getApp().getFeeVote ().doValidation (newLCL, *v);
|
||||
getApp().getFeatureTable ().doValidation (newLCL, *v);
|
||||
// we agreed to disagree
|
||||
closeTimeCorrect = false;
|
||||
closeTime = mPreviousLedger->getCloseTimeNC () + 1;
|
||||
}
|
||||
|
||||
v->sign (signingHash, mValPrivate);
|
||||
v->setTrusted ();
|
||||
getApp().getHashRouter ().addSuppression (signingHash); // suppress it if we receive it
|
||||
getApp().getValidations ().addValidation (v, "local");
|
||||
getApp().getOPs ().setLastValidation (v);
|
||||
Blob validation = v->getSigned ();
|
||||
protocol::TMValidation val;
|
||||
val.set_validation (&validation[0], validation.size ());
|
||||
int j = getApp().getPeers ().relayMessage (NULL,
|
||||
boost::make_shared<PackedMessage> (val, protocol::mtVALIDATION));
|
||||
WriteLog (lsINFO, LedgerConsensus) << "CNF Val " << newLCLHash << " to " << j << " peers";
|
||||
}
|
||||
else
|
||||
WriteLog (lsINFO, LedgerConsensus) << "CNF newLCL " << newLCLHash;
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: Prop=" << (mProposing ? "yes" : "no") << " val=" << (mValidating ? "yes" : "no") <<
|
||||
" corLCL=" << (mHaveCorrectLCL ? "yes" : "no") << " fail=" << (mConsensusFail ? "yes" : "no");
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->getLedgerSeq ();
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: TxSt = " << set->getHash () << ", close " << closeTime << (closeTimeCorrect ? "" : "X");
|
||||
|
||||
Ledger::pointer newOL = boost::make_shared<Ledger> (true, boost::ref (*newLCL));
|
||||
ScopedLock sl ( getApp().getLedgerMaster ().getLock ());
|
||||
CanonicalTXSet failedTransactions (set->getHash ());
|
||||
|
||||
// Apply disputed transactions that didn't get in
|
||||
TransactionEngine engine (newOL);
|
||||
BOOST_FOREACH (u256_lct_pair & it, mDisputes)
|
||||
{
|
||||
if (!it.second->getOurVote ())
|
||||
Ledger::pointer newLCL = boost::make_shared<Ledger> (false, boost::ref (*mPreviousLedger));
|
||||
|
||||
newLCL->peekTransactionMap ()->armDirty ();
|
||||
newLCL->peekAccountStateMap ()->armDirty ();
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Applying consensus set transactions to the last closed ledger";
|
||||
applyTransactions (set, newLCL, newLCL, failedTransactions, false);
|
||||
newLCL->updateSkipList ();
|
||||
newLCL->setClosed ();
|
||||
boost::shared_ptr<SHAMap::DirtyMap> acctNodes = newLCL->peekAccountStateMap ()->disarmDirty ();
|
||||
boost::shared_ptr<SHAMap::DirtyMap> txnNodes = newLCL->peekTransactionMap ()->disarmDirty ();
|
||||
|
||||
// write out dirty nodes (temporarily done here) Most come before setAccepted
|
||||
int fc;
|
||||
|
||||
while ((fc = SHAMap::flushDirty (*acctNodes, 256, hotACCOUNT_NODE, newLCL->getLedgerSeq ())) > 0)
|
||||
{
|
||||
// we voted NO
|
||||
try
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Test applying disputed transaction that did not get in";
|
||||
SerializerIterator sit (it.second->peekTransaction ());
|
||||
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction> (boost::ref (sit));
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty state nodes";
|
||||
}
|
||||
|
||||
if (applyTransaction (engine, txn, newOL, true, false))
|
||||
failedTransactions.push_back (txn);
|
||||
}
|
||||
catch (...)
|
||||
while ((fc = SHAMap::flushDirty (*txnNodes, 256, hotTRANSACTION_NODE, newLCL->getLedgerSeq ())) > 0)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty transaction nodes";
|
||||
}
|
||||
|
||||
newLCL->setAccepted (closeTime, mCloseResolution, closeTimeCorrect);
|
||||
newLCL->updateHash ();
|
||||
newLCL->setImmutable ();
|
||||
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Report: NewL = " << newLCL->getHash () << ":" << newLCL->getLedgerSeq ();
|
||||
uint256 newLCLHash = newLCL->getHash ();
|
||||
|
||||
if (ShouldLog (lsTRACE, LedgerConsensus))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerConsensus) << "newLCL";
|
||||
Json::Value p;
|
||||
newLCL->addJson (p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
|
||||
WriteLog (lsTRACE, LedgerConsensus) << p;
|
||||
}
|
||||
|
||||
statusChange (protocol::neACCEPTED_LEDGER, *newLCL);
|
||||
|
||||
if (mValidating && !mConsensusFail)
|
||||
{
|
||||
uint256 signingHash;
|
||||
SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
|
||||
(newLCLHash, getApp().getOPs ().getValidationTimeNC (), mValPublic, mProposing);
|
||||
v->setFieldU32 (sfLedgerSequence, newLCL->getLedgerSeq ());
|
||||
addLoad(v);
|
||||
|
||||
if (((newLCL->getLedgerSeq () + 1) % 256) == 0) // next ledger is flag ledger
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Failed to apply transaction we voted NO on";
|
||||
getApp().getFeeVote ().doValidation (newLCL, *v);
|
||||
getApp().getFeatureTable ().doValidation (newLCL, *v);
|
||||
}
|
||||
|
||||
v->sign (signingHash, mValPrivate);
|
||||
v->setTrusted ();
|
||||
getApp().getHashRouter ().addSuppression (signingHash); // suppress it if we receive it
|
||||
getApp().getValidations ().addValidation (v, "local");
|
||||
getApp().getOPs ().setLastValidation (v);
|
||||
Blob validation = v->getSigned ();
|
||||
protocol::TMValidation val;
|
||||
val.set_validation (&validation[0], validation.size ());
|
||||
int j = getApp().getPeers ().relayMessage (NULL,
|
||||
boost::make_shared<PackedMessage> (val, protocol::mtVALIDATION));
|
||||
WriteLog (lsINFO, LedgerConsensus) << "CNF Val " << newLCLHash << " to " << j << " peers";
|
||||
}
|
||||
else
|
||||
WriteLog (lsINFO, LedgerConsensus) << "CNF newLCL " << newLCLHash;
|
||||
|
||||
Ledger::pointer newOL = boost::make_shared<Ledger> (true, boost::ref (*newLCL));
|
||||
ScopedLock sl ( getApp().getLedgerMaster ().getLock ());
|
||||
|
||||
// Apply disputed transactions that didn't get in
|
||||
TransactionEngine engine (newOL);
|
||||
BOOST_FOREACH (u256_lct_pair & it, mDisputes)
|
||||
{
|
||||
if (!it.second->getOurVote ())
|
||||
{
|
||||
// we voted NO
|
||||
try
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Test applying disputed transaction that did not get in";
|
||||
SerializerIterator sit (it.second->peekTransaction ());
|
||||
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction> (boost::ref (sit));
|
||||
|
||||
if (applyTransaction (engine, txn, newOL, true, false))
|
||||
failedTransactions.push_back (txn);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Failed to apply transaction we voted NO on";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Applying transactions from current open ledger";
|
||||
applyTransactions (getApp().getLedgerMaster ().getCurrentLedger ()->peekTransactionMap (), newOL, newLCL,
|
||||
failedTransactions, true);
|
||||
getApp().getLedgerMaster ().pushLedger (newLCL, newOL, !mConsensusFail);
|
||||
mNewLedgerHash = newLCL->getHash ();
|
||||
mState = lcsACCEPTED;
|
||||
sl.unlock ();
|
||||
WriteLog (lsDEBUG, LedgerConsensus) << "Applying transactions from current open ledger";
|
||||
applyTransactions (getApp().getLedgerMaster ().getCurrentLedger ()->peekTransactionMap (), newOL, newLCL,
|
||||
failedTransactions, true);
|
||||
getApp().getLedgerMaster ().pushLedger (newLCL, newOL, !mConsensusFail);
|
||||
mNewLedgerHash = newLCL->getHash ();
|
||||
mState = lcsACCEPTED;
|
||||
sl.unlock ();
|
||||
|
||||
if (mValidating)
|
||||
{
|
||||
// see how close our close time is to other node's close time reports
|
||||
WriteLog (lsINFO, LedgerConsensus) << "We closed at " << boost::lexical_cast<std::string> (mCloseTime);
|
||||
uint64 closeTotal = mCloseTime;
|
||||
int closeCount = 1;
|
||||
|
||||
for (std::map<uint32, int>::iterator it = mCloseTimes.begin (), end = mCloseTimes.end (); it != end; ++it)
|
||||
if (mValidating)
|
||||
{
|
||||
// FIXME: Use median, not average
|
||||
WriteLog (lsINFO, LedgerConsensus) << boost::lexical_cast<std::string> (it->second) << " time votes for "
|
||||
<< boost::lexical_cast<std::string> (it->first);
|
||||
closeCount += it->second;
|
||||
closeTotal += static_cast<uint64> (it->first) * static_cast<uint64> (it->second);
|
||||
// see how close our close time is to other node's close time reports
|
||||
WriteLog (lsINFO, LedgerConsensus) << "We closed at " << boost::lexical_cast<std::string> (mCloseTime);
|
||||
uint64 closeTotal = mCloseTime;
|
||||
int closeCount = 1;
|
||||
|
||||
for (std::map<uint32, int>::iterator it = mCloseTimes.begin (), end = mCloseTimes.end (); it != end; ++it)
|
||||
{
|
||||
// FIXME: Use median, not average
|
||||
WriteLog (lsINFO, LedgerConsensus) << boost::lexical_cast<std::string> (it->second) << " time votes for "
|
||||
<< boost::lexical_cast<std::string> (it->first);
|
||||
closeCount += it->second;
|
||||
closeTotal += static_cast<uint64> (it->first) * static_cast<uint64> (it->second);
|
||||
}
|
||||
|
||||
closeTotal += (closeCount / 2);
|
||||
closeTotal /= closeCount;
|
||||
int offset = static_cast<int> (closeTotal) - static_cast<int> (mCloseTime);
|
||||
WriteLog (lsINFO, LedgerConsensus) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
|
||||
getApp().getOPs ().closeTimeOffset (offset);
|
||||
}
|
||||
|
||||
closeTotal += (closeCount / 2);
|
||||
closeTotal /= closeCount;
|
||||
int offset = static_cast<int> (closeTotal) - static_cast<int> (mCloseTime);
|
||||
WriteLog (lsINFO, LedgerConsensus) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
|
||||
getApp().getOPs ().closeTimeOffset (offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LedgerConsensus::endConsensus ()
|
||||
|
||||
@@ -250,6 +250,11 @@ private:
|
||||
static void logDeadlock (int dlTime)
|
||||
{
|
||||
WriteLog (lsWARNING, LoadManager) << "Server stalled for " << dlTime << " seconds.";
|
||||
|
||||
char const* fileName = getApp ().getMasterLock ().getFileName ();
|
||||
int lineNumber = getApp ().getMasterLock ().getLineNumber ();
|
||||
|
||||
WriteLog (lsWARNING, LoadManager) << "Master lock owned by " << File (fileName).getFileName ().toStdString () << ", line " << lineNumber;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -141,22 +141,20 @@ public:
|
||||
|
||||
/** Run the Beast unit tests.
|
||||
*/
|
||||
static void runBeastUnitTests ()
|
||||
static void runBeastUnitTests (std::string const& individualTest = "")
|
||||
{
|
||||
RippleUnitTests tr;
|
||||
|
||||
tr.setAssertOnFailure (false);
|
||||
tr.setPassesAreLogged (false);
|
||||
|
||||
tr.runAllTests ();
|
||||
|
||||
// Report
|
||||
for (int i = 0; i < tr.getNumResults (); ++i)
|
||||
if (individualTest.empty ())
|
||||
{
|
||||
UnitTests::TestResult const& r (*tr.getResult (i));
|
||||
|
||||
for (int j = 0; j < r.messages.size (); ++i)
|
||||
Log::out () << r.messages [j].toStdString ();
|
||||
tr.runAllTests ();
|
||||
}
|
||||
else
|
||||
{
|
||||
tr.runTest (individualTest.c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +216,15 @@ int rippleMain (int argc, char** argv)
|
||||
int iResult = 0;
|
||||
po::variables_map vm; // Map of options.
|
||||
|
||||
String importDescription;
|
||||
{
|
||||
importDescription <<
|
||||
"Import an existing node database (specified in the " <<
|
||||
"[" << ConfigSection::importNodeDatabase () << "] configuration file section) "
|
||||
"into the current node database (specified in the " <<
|
||||
"[" << ConfigSection::nodeDatabase () << "] configuration file section). ";
|
||||
}
|
||||
|
||||
// VFALCO TODO Replace boost program options with something from Beast.
|
||||
//
|
||||
// Set up option parsing.
|
||||
@@ -232,7 +239,7 @@ int rippleMain (int argc, char** argv)
|
||||
("standalone,a", "Run with no peers.")
|
||||
("testnet,t", "Run in test net mode.")
|
||||
("unittest,u", "Perform unit tests.")
|
||||
("unittest2", "Perform new unit tests.")
|
||||
("unittest2", po::value <std::string> ()->implicit_value (""), "Perform new unit tests.")
|
||||
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
|
||||
("quiet,q", "Reduce diagnotics.")
|
||||
("verbose,v", "Verbose logging.")
|
||||
@@ -242,7 +249,7 @@ int rippleMain (int argc, char** argv)
|
||||
("start", "Start from a fresh Ledger.")
|
||||
("net", "Get the initial ledger from the network.")
|
||||
("fg", "Run in the foreground.")
|
||||
("import", po::value<std::string> (), "Import old DB into new DB.")
|
||||
("import", importDescription.toStdString ().c_str ())
|
||||
;
|
||||
|
||||
// Interpret positional arguments as --parameters.
|
||||
@@ -250,8 +257,10 @@ int rippleMain (int argc, char** argv)
|
||||
p.add ("parameters", -1);
|
||||
|
||||
// These must be added before the Application object is created
|
||||
NodeStore::addBackendFactory (SqliteBackendFactory::getInstance ());
|
||||
NodeStore::addBackendFactory (KeyvaDBBackendFactory::getInstance ());
|
||||
NodeStore::addBackendFactory (LevelDBBackendFactory::getInstance ());
|
||||
NodeStore::addBackendFactory (NullBackendFactory::getInstance ());
|
||||
NodeStore::addBackendFactory (SqliteBackendFactory::getInstance ());
|
||||
#if RIPPLE_HYPERLEVELDB_AVAILABLE
|
||||
NodeStore::addBackendFactory (HyperLevelDBBackendFactory::getInstance ());
|
||||
#endif
|
||||
@@ -299,7 +308,7 @@ int rippleMain (int argc, char** argv)
|
||||
if (HaveSustain () &&
|
||||
!iResult && !vm.count ("parameters") && !vm.count ("fg") && !vm.count ("standalone") && !vm.count ("unittest"))
|
||||
{
|
||||
std::string logMe = DoSustain (theConfig.DEBUG_LOGFILE.c_str());
|
||||
std::string logMe = DoSustain (theConfig.DEBUG_LOGFILE.string());
|
||||
|
||||
if (!logMe.empty ())
|
||||
Log (lsWARNING) << logMe;
|
||||
@@ -331,7 +340,10 @@ int rippleMain (int argc, char** argv)
|
||||
|
||||
if (vm.count ("unittest2"))
|
||||
{
|
||||
runBeastUnitTests ();
|
||||
std::string const test = vm ["unittest2"].as <std::string> ();
|
||||
|
||||
runBeastUnitTests (test);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -351,8 +363,14 @@ int rippleMain (int argc, char** argv)
|
||||
|
||||
if (vm.count ("start")) theConfig.START_UP = Config::FRESH;
|
||||
|
||||
// Handle a one-time import option
|
||||
//
|
||||
if (vm.count ("import"))
|
||||
theConfig.DB_IMPORT = vm["import"].as<std::string> ();
|
||||
{
|
||||
String const optionString (vm ["import"].as <std::string> ());
|
||||
|
||||
theConfig.importNodeDatabase = parseDelimitedKeyValueString (optionString);
|
||||
}
|
||||
|
||||
if (vm.count ("ledger"))
|
||||
{
|
||||
|
||||
@@ -818,7 +818,7 @@ int Pathfinder::getPathsOut (const uint160& currencyID, const uint160& accountID
|
||||
return it->second;
|
||||
|
||||
int aFlags = mLedger->getSLEi(Ledger::getAccountRootIndex(accountID))->getFieldU32(sfFlags);
|
||||
bool bAuthRequired = aFlags & lsfRequireAuth;
|
||||
bool const bAuthRequired = (aFlags & lsfRequireAuth) != 0;
|
||||
|
||||
int count = 0;
|
||||
AccountItems& rippleLines (mRLCache->getRippleLines (accountID));
|
||||
|
||||
@@ -165,12 +165,12 @@ private:
|
||||
|
||||
void recvHello (protocol::TMHello & packet);
|
||||
void recvCluster (protocol::TMCluster & packet);
|
||||
void recvTransaction (protocol::TMTransaction & packet, ScopedLock & MasterLockHolder);
|
||||
void recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, ScopedLock & MasterLockHolder);
|
||||
void recvTransaction (protocol::TMTransaction & packet, Application::ScopedLockType& masterLockHolder);
|
||||
void recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, Application::ScopedLockType& masterLockHolder);
|
||||
void recvGetValidation (protocol::TMGetValidations & packet);
|
||||
void recvContact (protocol::TMContact & packet);
|
||||
void recvGetContacts (protocol::TMGetContacts & packet);
|
||||
void recvGetPeers (protocol::TMGetPeers & packet, ScopedLock & MasterLockHolder);
|
||||
void recvGetPeers (protocol::TMGetPeers & packet, Application::ScopedLockType& masterLockHolder);
|
||||
void recvPeers (protocol::TMPeers & packet);
|
||||
void recvGetObjectByHash (const boost::shared_ptr<protocol::TMGetObjectByHash>& packet);
|
||||
void recvPing (protocol::TMPing & packet);
|
||||
@@ -178,8 +178,8 @@ private:
|
||||
void recvSearchTransaction (protocol::TMSearchTransaction & packet);
|
||||
void recvGetAccount (protocol::TMGetAccount & packet);
|
||||
void recvAccount (protocol::TMAccount & packet);
|
||||
void recvGetLedger (protocol::TMGetLedger & packet, ScopedLock & MasterLockHolder);
|
||||
void recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet, ScopedLock & MasterLockHolder);
|
||||
void recvGetLedger (protocol::TMGetLedger & packet, Application::ScopedLockType& masterLockHolder);
|
||||
void recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet, Application::ScopedLockType& masterLockHolder);
|
||||
void recvStatus (protocol::TMStatusChange & packet);
|
||||
void recvPropose (const boost::shared_ptr<protocol::TMProposeSet>& packet);
|
||||
void recvHaveTxSet (protocol::TMHaveTransactionSet & packet);
|
||||
@@ -630,8 +630,11 @@ void PeerImp::handleReadBody (const boost::system::error_code& error)
|
||||
WriteLog (lsINFO, Peer) << "Peer: Body: Error: " << getIP () << ": " << error.category ().name () << ": " << error.message () << ": " << error;
|
||||
}
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
detach ("hrb", true);
|
||||
{
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
detach ("hrb", true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -651,276 +654,278 @@ void PeerImp::processReadBuffer ()
|
||||
|
||||
LoadEvent::autoptr event (getApp().getJobQueue ().getLoadEventAP (jtPEER, "PeerImp::read"));
|
||||
|
||||
ScopedLock sl (getApp().getMasterLock ());
|
||||
|
||||
// If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent.
|
||||
if (mHelloed == (type == protocol::mtHELLO))
|
||||
{
|
||||
WriteLog (lsWARNING, Peer) << "Wrong message type: " << type;
|
||||
detach ("prb1", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case protocol::mtHELLO:
|
||||
{
|
||||
event->reName ("PeerImp::hello");
|
||||
protocol::TMHello msg;
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvHello (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
// If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent.
|
||||
if (mHelloed == (type == protocol::mtHELLO))
|
||||
{
|
||||
WriteLog (lsWARNING, Peer) << "Wrong message type: " << type;
|
||||
detach ("prb1", true);
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtCLUSTER:
|
||||
else
|
||||
{
|
||||
event->reName ("PeerImp::cluster");
|
||||
protocol::TMCluster msg;
|
||||
switch (type)
|
||||
{
|
||||
case protocol::mtHELLO:
|
||||
{
|
||||
event->reName ("PeerImp::hello");
|
||||
protocol::TMHello msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvCluster (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvHello (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtERROR_MSG:
|
||||
{
|
||||
event->reName ("PeerImp::errormessage");
|
||||
protocol::TMErrorMsg msg;
|
||||
case protocol::mtCLUSTER:
|
||||
{
|
||||
event->reName ("PeerImp::cluster");
|
||||
protocol::TMCluster msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvErrorMessage (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvCluster (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
|
||||
case protocol::mtPING:
|
||||
{
|
||||
event->reName ("PeerImp::ping");
|
||||
protocol::TMPing msg;
|
||||
case protocol::mtERROR_MSG:
|
||||
{
|
||||
event->reName ("PeerImp::errormessage");
|
||||
protocol::TMErrorMsg msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPing (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvErrorMessage (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtGET_CONTACTS:
|
||||
{
|
||||
event->reName ("PeerImp::getcontacts");
|
||||
protocol::TMGetContacts msg;
|
||||
case protocol::mtPING:
|
||||
{
|
||||
event->reName ("PeerImp::ping");
|
||||
protocol::TMPing msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetContacts (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPing (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtCONTACT:
|
||||
{
|
||||
event->reName ("PeerImp::contact");
|
||||
protocol::TMContact msg;
|
||||
case protocol::mtGET_CONTACTS:
|
||||
{
|
||||
event->reName ("PeerImp::getcontacts");
|
||||
protocol::TMGetContacts msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvContact (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetContacts (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtGET_PEERS:
|
||||
{
|
||||
event->reName ("PeerImp::getpeers");
|
||||
protocol::TMGetPeers msg;
|
||||
case protocol::mtCONTACT:
|
||||
{
|
||||
event->reName ("PeerImp::contact");
|
||||
protocol::TMContact msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetPeers (msg, sl);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvContact (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtPEERS:
|
||||
{
|
||||
event->reName ("PeerImp::peers");
|
||||
protocol::TMPeers msg;
|
||||
case protocol::mtGET_PEERS:
|
||||
{
|
||||
event->reName ("PeerImp::getpeers");
|
||||
protocol::TMGetPeers msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPeers (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetPeers (msg, lock);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtSEARCH_TRANSACTION:
|
||||
{
|
||||
event->reName ("PeerImp::searchtransaction");
|
||||
protocol::TMSearchTransaction msg;
|
||||
case protocol::mtPEERS:
|
||||
{
|
||||
event->reName ("PeerImp::peers");
|
||||
protocol::TMPeers msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvSearchTransaction (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPeers (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtGET_ACCOUNT:
|
||||
{
|
||||
event->reName ("PeerImp::getaccount");
|
||||
protocol::TMGetAccount msg;
|
||||
case protocol::mtSEARCH_TRANSACTION:
|
||||
{
|
||||
event->reName ("PeerImp::searchtransaction");
|
||||
protocol::TMSearchTransaction msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetAccount (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvSearchTransaction (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtACCOUNT:
|
||||
{
|
||||
event->reName ("PeerImp::account");
|
||||
protocol::TMAccount msg;
|
||||
case protocol::mtGET_ACCOUNT:
|
||||
{
|
||||
event->reName ("PeerImp::getaccount");
|
||||
protocol::TMGetAccount msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvAccount (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetAccount (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtTRANSACTION:
|
||||
{
|
||||
event->reName ("PeerImp::transaction");
|
||||
protocol::TMTransaction msg;
|
||||
case protocol::mtACCOUNT:
|
||||
{
|
||||
event->reName ("PeerImp::account");
|
||||
protocol::TMAccount msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvTransaction (msg, sl);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvAccount (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtSTATUS_CHANGE:
|
||||
{
|
||||
event->reName ("PeerImp::statuschange");
|
||||
protocol::TMStatusChange msg;
|
||||
case protocol::mtTRANSACTION:
|
||||
{
|
||||
event->reName ("PeerImp::transaction");
|
||||
protocol::TMTransaction msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvStatus (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvTransaction (msg, lock);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtPROPOSE_LEDGER:
|
||||
{
|
||||
event->reName ("PeerImp::propose");
|
||||
boost::shared_ptr<protocol::TMProposeSet> msg = boost::make_shared<protocol::TMProposeSet> ();
|
||||
case protocol::mtSTATUS_CHANGE:
|
||||
{
|
||||
event->reName ("PeerImp::statuschange");
|
||||
protocol::TMStatusChange msg;
|
||||
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPropose (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvStatus (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtGET_LEDGER:
|
||||
{
|
||||
event->reName ("PeerImp::getledger");
|
||||
protocol::TMGetLedger msg;
|
||||
case protocol::mtPROPOSE_LEDGER:
|
||||
{
|
||||
event->reName ("PeerImp::propose");
|
||||
boost::shared_ptr<protocol::TMProposeSet> msg = boost::make_shared<protocol::TMProposeSet> ();
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetLedger (msg, sl);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvPropose (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtLEDGER_DATA:
|
||||
{
|
||||
event->reName ("PeerImp::ledgerdata");
|
||||
boost::shared_ptr<protocol::TMLedgerData> msg = boost::make_shared<protocol::TMLedgerData> ();
|
||||
case protocol::mtGET_LEDGER:
|
||||
{
|
||||
event->reName ("PeerImp::getledger");
|
||||
protocol::TMGetLedger msg;
|
||||
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvLedger (msg, sl);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetLedger (msg, lock);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtHAVE_SET:
|
||||
{
|
||||
event->reName ("PeerImp::haveset");
|
||||
protocol::TMHaveTransactionSet msg;
|
||||
case protocol::mtLEDGER_DATA:
|
||||
{
|
||||
event->reName ("PeerImp::ledgerdata");
|
||||
boost::shared_ptr<protocol::TMLedgerData> msg = boost::make_shared<protocol::TMLedgerData> ();
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvHaveTxSet (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvLedger (msg, lock);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtVALIDATION:
|
||||
{
|
||||
event->reName ("PeerImp::validation");
|
||||
boost::shared_ptr<protocol::TMValidation> msg = boost::make_shared<protocol::TMValidation> ();
|
||||
case protocol::mtHAVE_SET:
|
||||
{
|
||||
event->reName ("PeerImp::haveset");
|
||||
protocol::TMHaveTransactionSet msg;
|
||||
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvValidation (msg, sl);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvHaveTxSet (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtGET_VALIDATION:
|
||||
{
|
||||
protocol::TM msg;
|
||||
case protocol::mtVALIDATION:
|
||||
{
|
||||
event->reName ("PeerImp::validation");
|
||||
boost::shared_ptr<protocol::TMValidation> msg = boost::make_shared<protocol::TMValidation> ();
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recv (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvValidation (msg, lock);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
|
||||
#endif
|
||||
case protocol::mtGET_VALIDATION:
|
||||
{
|
||||
protocol::TM msg;
|
||||
|
||||
case protocol::mtGET_OBJECTS:
|
||||
{
|
||||
event->reName ("PeerImp::getobjects");
|
||||
boost::shared_ptr<protocol::TMGetObjectByHash> msg = boost::make_shared<protocol::TMGetObjectByHash> ();
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recv (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetObjectByHash (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case protocol::mtPROOFOFWORK:
|
||||
{
|
||||
event->reName ("PeerImp::proofofwork");
|
||||
protocol::TMProofWork msg;
|
||||
case protocol::mtGET_OBJECTS:
|
||||
{
|
||||
event->reName ("PeerImp::getobjects");
|
||||
boost::shared_ptr<protocol::TMGetObjectByHash> msg = boost::make_shared<protocol::TMGetObjectByHash> ();
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvProofWork (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvGetObjectByHash (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol::mtPROOFOFWORK:
|
||||
{
|
||||
event->reName ("PeerImp::proofofwork");
|
||||
protocol::TMProofWork msg;
|
||||
|
||||
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
|
||||
recvProofWork (msg);
|
||||
else
|
||||
WriteLog (lsWARNING, Peer) << "parse error: " << type;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
event->reName ("PeerImp::unknown");
|
||||
WriteLog (lsWARNING, Peer) << "Unknown Msg: " << type;
|
||||
WriteLog (lsWARNING, Peer) << strHex (&mReadbuf[0], mReadbuf.size ());
|
||||
default:
|
||||
event->reName ("PeerImp::unknown");
|
||||
WriteLog (lsWARNING, Peer) << "Unknown Msg: " << type;
|
||||
WriteLog (lsWARNING, Peer) << strHex (&mReadbuf[0], mReadbuf.size ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1111,9 +1116,9 @@ static void checkTransaction (Job&, int flags, SerializedTransaction::pointer st
|
||||
#endif
|
||||
}
|
||||
|
||||
void PeerImp::recvTransaction (protocol::TMTransaction& packet, ScopedLock& MasterLockHolder)
|
||||
void PeerImp::recvTransaction (protocol::TMTransaction& packet, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
Transaction::pointer tx;
|
||||
#ifndef TRUST_NETWORK
|
||||
|
||||
@@ -1376,9 +1381,9 @@ static void checkValidation (Job&, SerializedValidation::pointer val, uint256 si
|
||||
#endif
|
||||
}
|
||||
|
||||
void PeerImp::recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, ScopedLock& MasterLockHolder)
|
||||
void PeerImp::recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
if (packet->validation ().size () < 50)
|
||||
{
|
||||
@@ -1464,9 +1469,9 @@ void PeerImp::recvGetContacts (protocol::TMGetContacts& packet)
|
||||
// Return a list of your favorite people
|
||||
// TODO: filter out all the LAN peers
|
||||
// TODO: filter out the peer you are talking to
|
||||
void PeerImp::recvGetPeers (protocol::TMGetPeers& packet, ScopedLock& MasterLockHolder)
|
||||
void PeerImp::recvGetPeers (protocol::TMGetPeers& packet, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
std::vector<std::string> addrs;
|
||||
|
||||
getApp().getPeers ().getTopNAddrs (30, addrs);
|
||||
@@ -1550,7 +1555,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptr<protocol::TMGetObject
|
||||
if (obj.has_hash () && (obj.hash ().size () == (256 / 8)))
|
||||
{
|
||||
memcpy (hash.begin (), obj.hash ().data (), 256 / 8);
|
||||
NodeObject::pointer hObj = getApp().getNodeStore ().retrieve (hash);
|
||||
NodeObject::pointer hObj = getApp().getNodeStore ().fetch (hash);
|
||||
|
||||
if (hObj)
|
||||
{
|
||||
@@ -1780,7 +1785,7 @@ void PeerImp::recvStatus (protocol::TMStatusChange& packet)
|
||||
mMaxLedger = packet.lastseq ();
|
||||
}
|
||||
|
||||
void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLockHolder)
|
||||
void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
SHAMap::pointer map;
|
||||
protocol::TMLedgerData reply;
|
||||
@@ -1930,7 +1935,7 @@ void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLo
|
||||
}
|
||||
|
||||
if (ledger->isImmutable ())
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
else
|
||||
{
|
||||
WriteLog (lsWARNING, Peer) << "Request for data from mutable ledger";
|
||||
@@ -2064,9 +2069,9 @@ void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLo
|
||||
sendPacket (oPacket, true);
|
||||
}
|
||||
|
||||
void PeerImp::recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet_ptr, ScopedLock& MasterLockHolder)
|
||||
void PeerImp::recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet_ptr, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
MasterLockHolder.unlock ();
|
||||
masterLockHolder.unlock ();
|
||||
protocol::TMLedgerData& packet = *packet_ptr;
|
||||
|
||||
if (packet.nodes ().size () <= 0)
|
||||
|
||||
@@ -177,4 +177,5 @@ bool ProofOfWork::validateToken (const std::string& strToken)
|
||||
return boost::regex_match (strToken, smMatch, reToken);
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -231,3 +231,72 @@ IProofOfWorkFactory* IProofOfWorkFactory::New ()
|
||||
return new ProofOfWorkFactory;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class ProofOfWorkTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
ProofOfWorkTests () : UnitTest ("ProofOfWork", "ripple")
|
||||
{
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
using namespace ripple;
|
||||
|
||||
ProofOfWorkFactory gen;
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
|
||||
String s;
|
||||
|
||||
s << "solve difficulty " << String (pow.getDifficulty ());
|
||||
beginTest ("solve");
|
||||
|
||||
uint256 solution = pow.solve (16777216);
|
||||
|
||||
expect (! solution.isZero (), "Should be solved");
|
||||
|
||||
expect (pow.checkSolution (solution), "Should be checked");
|
||||
|
||||
// Why is this emitted?
|
||||
//WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
|
||||
|
||||
POWResult r = gen.checkProof (pow.getToken (), uint256 ());
|
||||
|
||||
expect (r == powBADNONCE, "Should show bad nonce for empty solution");
|
||||
|
||||
expect (gen.checkProof (pow.getToken (), solution) == powOK, "Solution should check with issuer");
|
||||
|
||||
//WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
|
||||
|
||||
expect (gen.checkProof (pow.getToken (), solution) == powREUSED, "Reuse solution should be detected");
|
||||
|
||||
#ifdef SOLVE_POWS
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
gen.setDifficulty (i);
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (131072);
|
||||
|
||||
if (solution.isZero ())
|
||||
{
|
||||
//WriteLog (lsINFO, ProofOfWork) << "Giving up";
|
||||
}
|
||||
else
|
||||
{
|
||||
//WriteLog (lsINFO, ProofOfWork) << "Solution found";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
{
|
||||
//WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
static ProofOfWorkTests proofOfWorkTests;
|
||||
|
||||
@@ -4,64 +4,3 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (ProofOfWork_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ProofOfWork_test )
|
||||
{
|
||||
using namespace ripple;
|
||||
|
||||
ProofOfWorkFactory gen;
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (16777216);
|
||||
|
||||
if (solution.isZero ())
|
||||
BOOST_FAIL ("Unable to solve proof of work");
|
||||
|
||||
if (!pow.checkSolution (solution))
|
||||
BOOST_FAIL ("Solution did not check");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
|
||||
POWResult r = gen.checkProof (pow.getToken (), uint256 ());
|
||||
|
||||
if (r != powBADNONCE)
|
||||
{
|
||||
Log (lsFATAL) << "POWResult = " << static_cast<int> (r);
|
||||
BOOST_FAIL ("Empty solution didn't show bad nonce");
|
||||
}
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
BOOST_FAIL ("Solution did not check with issuer");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powREUSED)
|
||||
BOOST_FAIL ("Reuse solution not detected");
|
||||
|
||||
#ifdef SOLVE_POWS
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
gen.setDifficulty (i);
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (131072);
|
||||
|
||||
if (solution.isZero ())
|
||||
WriteLog (lsINFO, ProofOfWork) << "Giving up";
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, ProofOfWork) << "Solution found";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
{
|
||||
WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
@@ -205,7 +205,7 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& ha
|
||||
|
||||
if (node)
|
||||
{
|
||||
#ifdef BEAST_DEBUG
|
||||
#if BEAST_DEBUG
|
||||
|
||||
if (node->getNodeHash () != hash)
|
||||
{
|
||||
@@ -213,7 +213,7 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& ha
|
||||
WriteLog (lsFATAL, SHAMap) << "ID: " << id;
|
||||
WriteLog (lsFATAL, SHAMap) << "TgtHash " << hash;
|
||||
WriteLog (lsFATAL, SHAMap) << "NodHash " << node->getNodeHash ();
|
||||
throw std::runtime_error ("invalid node");
|
||||
Throw (std::runtime_error ("invalid node"));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -230,7 +230,7 @@ SHAMapTreeNode* SHAMap::getNodePointer (const SHAMapNode& id, uint256 const& has
|
||||
SHAMapTreeNode* ret = getNodePointerNT (id, hash);
|
||||
|
||||
if (!ret)
|
||||
throw SHAMapMissingNode (mType, id, hash);
|
||||
Throw (SHAMapMissingNode (mType, id, hash));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ SHAMapTreeNode* SHAMap::getNodePointer (const SHAMapNode& id, uint256 const& has
|
||||
SHAMapTreeNode* ret = getNodePointerNT (id, hash, filter);
|
||||
|
||||
if (!ret)
|
||||
throw SHAMapMissingNode (mType, id, hash);
|
||||
Throw (SHAMapMissingNode (mType, id, hash));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -493,7 +493,7 @@ SHAMapItem::pointer SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNT
|
||||
firstNode = firstBelow (firstNode);
|
||||
|
||||
if (!firstNode || firstNode->isInner ())
|
||||
throw std::runtime_error ("missing/corrupt node");
|
||||
Throw (std::runtime_error ("missing/corrupt node"));
|
||||
|
||||
type = firstNode->getType ();
|
||||
return firstNode->peekItem ();
|
||||
@@ -531,7 +531,7 @@ SHAMapItem::pointer SHAMap::peekPrevItem (uint256 const& id)
|
||||
SHAMapTreeNode* item = firstBelow (node.get ());
|
||||
|
||||
if (!item)
|
||||
throw std::runtime_error ("missing node");
|
||||
Throw (std::runtime_error ("missing node"));
|
||||
|
||||
return item->peekItem ();
|
||||
}
|
||||
@@ -597,7 +597,7 @@ bool SHAMap::delItem (uint256 const& id)
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
Throw (std::runtime_error ("missing node"));
|
||||
|
||||
SHAMapTreeNode::pointer leaf = stack.top ();
|
||||
stack.pop ();
|
||||
@@ -678,7 +678,7 @@ bool SHAMap::addGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasMeta
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
Throw (std::runtime_error ("missing node"));
|
||||
|
||||
SHAMapTreeNode::pointer node = stack.top ();
|
||||
stack.pop ();
|
||||
@@ -703,7 +703,7 @@ bool SHAMap::addGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasMeta
|
||||
WriteLog (lsFATAL, SHAMap) << "NewNode: " << *newNode;
|
||||
dump ();
|
||||
assert (false);
|
||||
throw std::runtime_error ("invalid inner node");
|
||||
Throw (std::runtime_error ("invalid inner node"));
|
||||
}
|
||||
|
||||
trackNewNode (newNode);
|
||||
@@ -776,7 +776,7 @@ bool SHAMap::updateGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasM
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
Throw (std::runtime_error ("missing node"));
|
||||
|
||||
SHAMapTreeNode::pointer node = stack.top ();
|
||||
stack.pop ();
|
||||
@@ -810,7 +810,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal (const SHAMapNode& id, uint256
|
||||
SHAMapTreeNode::pointer ret = fetchNodeExternalNT (id, hash);
|
||||
|
||||
if (!ret)
|
||||
throw SHAMapMissingNode (mType, id, hash);
|
||||
Throw (SHAMapMissingNode (mType, id, hash));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -822,7 +822,10 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternalNT (const SHAMapNode& id, uint2
|
||||
if (!getApp().running ())
|
||||
return ret;
|
||||
|
||||
NodeObject::pointer obj (getApp().getNodeStore ().retrieve (hash));
|
||||
// These are for diagnosing a crash on exit
|
||||
Application& app (getApp ());
|
||||
NodeStore& nodeStore (app.getNodeStore ());
|
||||
NodeObject::pointer obj (nodeStore.fetch (hash));
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
@@ -885,8 +888,11 @@ bool SHAMap::fetchRoot (uint256 const& hash, SHAMapSyncFilter* filter)
|
||||
}
|
||||
|
||||
SHAMapTreeNode::pointer newRoot = fetchNodeExternalNT(SHAMapNode(), hash);
|
||||
|
||||
if (newRoot)
|
||||
{
|
||||
root = newRoot;
|
||||
}
|
||||
else
|
||||
{
|
||||
Blob nodeData;
|
||||
@@ -935,7 +941,7 @@ int SHAMap::flushDirty (DirtyMap& map, int maxNodes, NodeObjectType t, uint32 se
|
||||
|
||||
#endif
|
||||
|
||||
getApp().getNodeStore ().store (t, seq, s.peekData (), it->second->getNodeHash ());
|
||||
getApp().getNodeStore ().store (t, seq, s.modData (), it->second->getNodeHash ());
|
||||
|
||||
if (flushed++ >= maxNodes)
|
||||
return flushed;
|
||||
|
||||
@@ -128,7 +128,7 @@ SHAMapNode SHAMapNode::getChildNodeID (int m) const
|
||||
// Which branch would contain the specified hash
|
||||
int SHAMapNode::selectBranch (uint256 const& hash) const
|
||||
{
|
||||
#ifdef PARANOID
|
||||
#if RIPPLE_VERIFY_NODEOBJECT_KEYS
|
||||
|
||||
if (mDepth >= 64)
|
||||
{
|
||||
|
||||
@@ -243,7 +243,7 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, SHANodeFormat format,
|
||||
{
|
||||
Serializer s;
|
||||
root->addRaw (s, snfPREFIX);
|
||||
filter->gotNode (false, *root, root->getNodeHash (), s.peekData (), root->getType ());
|
||||
filter->gotNode (false, *root, root->getNodeHash (), s.modData (), root->getType ());
|
||||
}
|
||||
|
||||
return SHAMapAddNode::useful ();
|
||||
@@ -281,7 +281,7 @@ SHAMapAddNode SHAMap::addRootNode (uint256 const& hash, Blob const& rootNode, SH
|
||||
{
|
||||
Serializer s;
|
||||
root->addRaw (s, snfPREFIX);
|
||||
filter->gotNode (false, *root, root->getNodeHash (), s.peekData (), root->getType ());
|
||||
filter->gotNode (false, *root, root->getNodeHash (), s.modData (), root->getType ());
|
||||
}
|
||||
|
||||
return SHAMapAddNode::useful ();
|
||||
@@ -345,7 +345,7 @@ SHAMapAddNode SHAMap::addKnownNode (const SHAMapNode& node, Blob const& rawNode,
|
||||
{
|
||||
Serializer s;
|
||||
newNode->addRaw (s, snfPREFIX);
|
||||
filter->gotNode (false, node, iNode->getChildHash (branch), s.peekData (), newNode->getType ());
|
||||
filter->gotNode (false, node, iNode->getChildHash (branch), s.modData (), newNode->getType ());
|
||||
}
|
||||
|
||||
mTNByID[node] = newNode;
|
||||
|
||||
@@ -12,29 +12,18 @@
|
||||
class SHAMapSyncFilter
|
||||
{
|
||||
public:
|
||||
SHAMapSyncFilter ()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SHAMapSyncFilter ()
|
||||
{
|
||||
}
|
||||
virtual ~SHAMapSyncFilter () { }
|
||||
|
||||
// Note that the nodeData is overwritten by this call
|
||||
virtual void gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
SHAMapTreeNode::TNType type)
|
||||
{
|
||||
}
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType type) = 0;
|
||||
|
||||
virtual bool haveNode (SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob& nodeData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Blob& nodeData) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -9,7 +9,7 @@ ConsensusTransSetSF::ConsensusTransSetSF ()
|
||||
}
|
||||
|
||||
void ConsensusTransSetSF::gotNode (bool fromFilter, const SHAMapNode& id, uint256 const& nodeHash,
|
||||
Blob const& nodeData, SHAMapTreeNode::TNType type)
|
||||
Blob& nodeData, SHAMapTreeNode::TNType type)
|
||||
{
|
||||
if (fromFilter)
|
||||
return;
|
||||
@@ -70,7 +70,7 @@ AccountStateSF::AccountStateSF (uint32 ledgerSeq)
|
||||
void AccountStateSF::gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType)
|
||||
{
|
||||
getApp().getNodeStore ().store (hotACCOUNT_NODE, mLedgerSeq, nodeData, nodeHash);
|
||||
@@ -93,7 +93,7 @@ TransactionStateSF::TransactionStateSF (uint32 ledgerSeq)
|
||||
void TransactionStateSF::gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType type)
|
||||
{
|
||||
getApp().getNodeStore ().store (
|
||||
|
||||
@@ -17,10 +17,11 @@ class ConsensusTransSetSF : public SHAMapSyncFilter
|
||||
public:
|
||||
ConsensusTransSetSF ();
|
||||
|
||||
// Note that the nodeData is overwritten by this call
|
||||
void gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType);
|
||||
|
||||
bool haveNode (SHAMapNode const& id,
|
||||
@@ -35,10 +36,11 @@ class AccountStateSF : public SHAMapSyncFilter
|
||||
public:
|
||||
explicit AccountStateSF (uint32 ledgerSeq);
|
||||
|
||||
// Note that the nodeData is overwritten by this call
|
||||
void gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType);
|
||||
|
||||
bool haveNode (SHAMapNode const& id,
|
||||
@@ -56,10 +58,11 @@ class TransactionStateSF : public SHAMapSyncFilter
|
||||
public:
|
||||
explicit TransactionStateSF (uint32 ledgerSeq);
|
||||
|
||||
// Note that the nodeData is overwritten by this call
|
||||
void gotNode (bool fromFilter,
|
||||
SHAMapNode const& id,
|
||||
uint256 const& nodeHash,
|
||||
Blob const& nodeData,
|
||||
Blob& nodeData,
|
||||
SHAMapTreeNode::TNType);
|
||||
|
||||
bool haveNode (SHAMapNode const& id,
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
SHAMapTreeNode::SHAMapTreeNode (uint32 seq, const SHAMapNode& nodeID) : SHAMapNode (nodeID), mHash (0),
|
||||
mSeq (seq), mAccessSeq (seq), mType (tnERROR), mIsBranch (0), mFullBelow (false)
|
||||
SHAMapTreeNode::SHAMapTreeNode (uint32 seq, const SHAMapNode& nodeID)
|
||||
: SHAMapNode (nodeID)
|
||||
, mHash (uint64(0))
|
||||
, mSeq (seq)
|
||||
, mAccessSeq (seq)
|
||||
, mType (tnERROR)
|
||||
, mIsBranch (0)
|
||||
, mFullBelow (false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -201,7 +207,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, uint3
|
||||
if (hashValid)
|
||||
{
|
||||
mHash = hash;
|
||||
#ifdef PARANOID
|
||||
#if RIPPLE_VERIFY_NODEOBJECT_KEYS
|
||||
updateHash ();
|
||||
assert (mHash == hash);
|
||||
#endif
|
||||
@@ -219,7 +225,7 @@ bool SHAMapTreeNode::updateHash ()
|
||||
if (mIsBranch != 0)
|
||||
{
|
||||
nh = Serializer::getPrefixHash (HashPrefix::innerNode, reinterpret_cast<unsigned char*> (mHashes), sizeof (mHashes));
|
||||
#ifdef PARANOID
|
||||
#if RIPPLE_VERIFY_NODEOBJECT_KEYS
|
||||
Serializer s;
|
||||
s.add32 (HashPrefix::innerNode);
|
||||
|
||||
|
||||
@@ -20,9 +20,13 @@ TransactionAcquire::TransactionAcquire (uint256 const& hash)
|
||||
|
||||
static void TACompletionHandler (uint256 hash, SHAMap::pointer map)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
getApp().getOPs ().mapComplete (hash, map);
|
||||
getApp().getInboundLedgers ().dropLedger (hash);
|
||||
{
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
getApp().getOPs ().mapComplete (hash, map);
|
||||
|
||||
getApp().getInboundLedgers ().dropLedger (hash);
|
||||
}
|
||||
}
|
||||
|
||||
void TransactionAcquire::done ()
|
||||
@@ -51,20 +55,18 @@ void TransactionAcquire::onTimer (bool progress, boost::recursive_mutex::scoped_
|
||||
if (getTimeouts () > 10)
|
||||
{
|
||||
WriteLog (lsWARNING, TransactionAcquire) << "Ten timeouts on TX set " << getHash ();
|
||||
{ // FIXME: Acquire the master lock here can deadlock
|
||||
psl.unlock();
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
|
||||
psl.unlock();
|
||||
{
|
||||
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
|
||||
|
||||
if (getApp().getOPs ().stillNeedTXSet (mHash))
|
||||
{
|
||||
WriteLog (lsWARNING, TransactionAcquire) << "Still need it";
|
||||
mTimeouts = 0;
|
||||
aggressive = true;
|
||||
}
|
||||
if (getApp().getOPs ().stillNeedTXSet (mHash))
|
||||
{
|
||||
WriteLog (lsWARNING, TransactionAcquire) << "Still need it";
|
||||
mTimeouts = 0;
|
||||
aggressive = true;
|
||||
}
|
||||
psl.lock();
|
||||
}
|
||||
psl.lock();
|
||||
|
||||
if (!aggressive)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user