Rename to PathRequest, begin include dependency analysis in ripple_client

This commit is contained in:
Vinnie Falco
2013-06-10 16:52:19 -07:00
parent e2c92ee8a4
commit c23b088755
14 changed files with 141 additions and 108 deletions

View File

@@ -22,4 +22,53 @@
@ingroup ripple_client @ingroup ripple_client
*/ */
#include <boost/unordered_set.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#if 0
#include "ripple_client.h" #include "ripple_client.h"
#include "../ripple_basics/ripple_basics.h"
#include "../ripple_data/ripple_data.h"
// Order and indentation reflect the hierarchy of dependencies
#include "src/cpp/ripple/ripple_HashedObject.h"
#include "src/cpp/ripple/ripple_SHAMapItem.h"
#include "src/cpp/ripple/ripple_SHAMapNode.h"
#include "src/cpp/ripple/ripple_SHAMapAddNode.h"
#include "src/cpp/ripple/ripple_SHAMapMissingNode.h"
#include "src/cpp/ripple/ripple_SHAMapTreeNode.h"
#include "src/cpp/ripple/ripple_SHAMapSyncFilter.h"
#include "src/cpp/ripple/ripple_SHAMap.h"
#include "src/cpp/ripple/ripple_SerializedTransaction.h"
#include "src/cpp/ripple/ripple_SerializedLedger.h"
#include "src/cpp/ripple/TransactionMeta.h"
#include "src/cpp/ripple/Transaction.h"
#include "src/cpp/ripple/AccountState.h"
#include "src/cpp/ripple/NicknameState.h"
#include "src/cpp/ripple/Ledger.h"
#include "src/cpp/ripple/LedgerEntrySet.h"
#include "src/cpp/ripple/TransactionEngine.h"
#include "src/cpp/ripple/LoadManager.h"
#include "src/cpp/ripple/ripple_Peer.h"
#include "src/cpp/ripple/ripple_PeerSet.h"
#include "src/cpp/ripple/ripple_LedgerAcquire.h"
#include "src/cpp/ripple/ripple_LedgerHistory.h"
#include "src/cpp/ripple/ripple_CanonicalTXSet.h"
#include "src/cpp/ripple/LedgerMaster.h"
#include "src/cpp/ripple/ripple_InfoSub.h"
#include "src/cpp/ripple/SerializedValidation.h"
#include "src/cpp/ripple/LedgerProposal.h"
#include "src/cpp/ripple/ripple_AcceptedLedgerTx.h"
#include "src/cpp/ripple/NetworkOPs.h"
// Application.h needs too much stuff.
#include "src/cpp/ripple/Application.h"
#include "src/cpp/ripple/ripple_InfoSub.cpp"
#endif

View File

@@ -32,6 +32,4 @@
#ifndef RIPPLE_CLIENT_H #ifndef RIPPLE_CLIENT_H
#define RIPPLE_CLIENT_H #define RIPPLE_CLIENT_H
#include "modules/ripple_basics/ripple_basics.h"
#endif #endif

View File

@@ -197,6 +197,15 @@
// //
// ----------- // -----------
#include "src/cpp/ripple/TransactionMaster.h"
#include "src/cpp/ripple/Wallet.h"
#include "src/cpp/ripple/WSDoor.h"
#include "src/cpp/ripple/SNTPClient.h"
#include "src/cpp/ripple/RPCHandler.h"
#include "src/cpp/ripple/TransactionQueue.h"
#include "src/cpp/ripple/OrderBookDB.h"
#include "src/cpp/ripple/ripple_DatabaseCon.h"
#include "src/cpp/ripple/Application.h" #include "src/cpp/ripple/Application.h"
#include "src/cpp/ripple/AutoSocket.h" #include "src/cpp/ripple/AutoSocket.h"
#include "src/cpp/ripple/CallRPC.h" #include "src/cpp/ripple/CallRPC.h"
@@ -210,8 +219,7 @@
#include "src/cpp/ripple/OfferCancelTransactor.h" #include "src/cpp/ripple/OfferCancelTransactor.h"
#include "src/cpp/ripple/OfferCreateTransactor.h" #include "src/cpp/ripple/OfferCreateTransactor.h"
#include "src/cpp/ripple/OrderBook.h" #include "src/cpp/ripple/OrderBook.h"
#include "src/cpp/ripple/OrderBookDB.h" #include "src/cpp/ripple/ripple_PathRequest.h"
#include "src/cpp/ripple/PFRequest.h"
#include "src/cpp/ripple/ParameterTable.h" #include "src/cpp/ripple/ParameterTable.h"
#include "src/cpp/ripple/ParseSection.h" #include "src/cpp/ripple/ParseSection.h"
#include "src/cpp/ripple/Pathfinder.h" #include "src/cpp/ripple/Pathfinder.h"
@@ -220,24 +228,18 @@
#include "src/cpp/ripple/RPC.h" #include "src/cpp/ripple/RPC.h"
#include "src/cpp/ripple/RPCDoor.h" #include "src/cpp/ripple/RPCDoor.h"
#include "src/cpp/ripple/RPCErr.h" #include "src/cpp/ripple/RPCErr.h"
#include "src/cpp/ripple/RPCHandler.h"
#include "src/cpp/ripple/RPCServer.h" #include "src/cpp/ripple/RPCServer.h"
#include "src/cpp/ripple/RPCSub.h" #include "src/cpp/ripple/RPCSub.h"
#include "src/cpp/ripple/RegularKeySetTransactor.h" #include "src/cpp/ripple/RegularKeySetTransactor.h"
#include "src/cpp/ripple/RippleCalc.h" #include "src/cpp/ripple/RippleCalc.h"
#include "src/cpp/ripple/RippleState.h" #include "src/cpp/ripple/RippleState.h"
#include "src/cpp/ripple/SNTPClient.h"
#include "src/cpp/ripple/SerializedValidation.h" #include "src/cpp/ripple/SerializedValidation.h"
#include "src/cpp/ripple/TransactionMaster.h"
#include "src/cpp/ripple/TransactionQueue.h"
#include "src/cpp/ripple/Transactor.h" #include "src/cpp/ripple/Transactor.h"
#include "src/cpp/ripple/AccountSetTransactor.h" #include "src/cpp/ripple/AccountSetTransactor.h"
#include "src/cpp/ripple/TrustSetTransactor.h" #include "src/cpp/ripple/TrustSetTransactor.h"
#include "src/cpp/ripple/Version.h" #include "src/cpp/ripple/Version.h"
#include "src/cpp/ripple/WSConnection.h" #include "src/cpp/ripple/WSConnection.h"
#include "src/cpp/ripple/WSDoor.h"
#include "src/cpp/ripple/WSHandler.h" #include "src/cpp/ripple/WSHandler.h"
#include "src/cpp/ripple/Wallet.h"
#include "src/cpp/ripple/WalletAddTransactor.h" #include "src/cpp/ripple/WalletAddTransactor.h"
#include "../websocketpp/src/logger/logger.hpp" // for ripple_LogWebSockets.cpp #include "../websocketpp/src/logger/logger.hpp" // for ripple_LogWebSockets.cpp
@@ -300,7 +302,6 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/Pathfinder.cpp" #include "src/cpp/ripple/Pathfinder.cpp"
#include "src/cpp/ripple/PaymentTransactor.cpp" #include "src/cpp/ripple/PaymentTransactor.cpp"
#include "src/cpp/ripple/PeerDoor.cpp" #include "src/cpp/ripple/PeerDoor.cpp"
#include "src/cpp/ripple/PFRequest.cpp"
#include "src/cpp/ripple/RegularKeySetTransactor.cpp" #include "src/cpp/ripple/RegularKeySetTransactor.cpp"
#include "src/cpp/ripple/RippleCalc.cpp" #include "src/cpp/ripple/RippleCalc.cpp"
#include "src/cpp/ripple/RippleState.cpp" // no log #include "src/cpp/ripple/RippleState.cpp" // no log
@@ -355,6 +356,7 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_LoadMonitor.cpp" #include "src/cpp/ripple/ripple_LoadMonitor.cpp"
#include "src/cpp/ripple/ripple_LogWebsockets.cpp" #include "src/cpp/ripple/ripple_LogWebsockets.cpp"
#include "src/cpp/ripple/ripple_LoadFeeTrack.cpp" #include "src/cpp/ripple/ripple_LoadFeeTrack.cpp"
#include "src/cpp/ripple/ripple_PathRequest.cpp"
#include "src/cpp/ripple/ripple_Peer.cpp" #include "src/cpp/ripple/ripple_Peer.cpp"
#include "src/cpp/ripple/ripple_Peers.cpp" #include "src/cpp/ripple/ripple_Peers.cpp"
#include "src/cpp/ripple/ripple_PeerSet.cpp" #include "src/cpp/ripple/ripple_PeerSet.cpp"

View File

@@ -990,7 +990,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\PFRequest.cpp"> <ClCompile Include="src\cpp\ripple\ripple_PathRequest.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@@ -1745,7 +1745,7 @@
<ClInclude Include="src\cpp\ripple\Pathfinder.h" /> <ClInclude Include="src\cpp\ripple\Pathfinder.h" />
<ClInclude Include="src\cpp\ripple\PaymentTransactor.h" /> <ClInclude Include="src\cpp\ripple\PaymentTransactor.h" />
<ClInclude Include="src\cpp\ripple\PeerDoor.h" /> <ClInclude Include="src\cpp\ripple\PeerDoor.h" />
<ClInclude Include="src\cpp\ripple\PFRequest.h" /> <ClInclude Include="src\cpp\ripple\ripple_PathRequest.h" />
<ClInclude Include="src\cpp\ripple\RegularKeySetTransactor.h" /> <ClInclude Include="src\cpp\ripple\RegularKeySetTransactor.h" />
<ClInclude Include="src\cpp\ripple\RippleCalc.h" /> <ClInclude Include="src\cpp\ripple\RippleCalc.h" />
<ClInclude Include="src\cpp\ripple\RippleState.h" /> <ClInclude Include="src\cpp\ripple\RippleState.h" />

View File

@@ -91,9 +91,6 @@
<Filter Include="2. Empty\ripple_net"> <Filter Include="2. Empty\ripple_net">
<UniqueIdentifier>{7f76ce57-c428-487e-97a0-979c0990a81d}</UniqueIdentifier> <UniqueIdentifier>{7f76ce57-c428-487e-97a0-979c0990a81d}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="2. Empty\ripple_client">
<UniqueIdentifier>{97c96b68-70fd-4679-89fc-c1c8c87c265e}</UniqueIdentifier>
</Filter>
<Filter Include="2. Empty\ripple_db"> <Filter Include="2. Empty\ripple_db">
<UniqueIdentifier>{a5190241-c5bc-4e23-8ef1-6adf757c75e3}</UniqueIdentifier> <UniqueIdentifier>{a5190241-c5bc-4e23-8ef1-6adf757c75e3}</UniqueIdentifier>
</Filter> </Filter>
@@ -130,9 +127,12 @@
<Filter Include="1. Modules\ripple_data\protocol"> <Filter Include="1. Modules\ripple_data\protocol">
<UniqueIdentifier>{2f3572a9-2882-4656-ab93-82b7761c9e3d}</UniqueIdentifier> <UniqueIdentifier>{2f3572a9-2882-4656-ab93-82b7761c9e3d}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="1. Modules\ripple_ledger"> <Filter Include="2. Empty\ripple_ledger">
<UniqueIdentifier>{b6175f9a-7d46-4b57-877f-f58b0b3bba89}</UniqueIdentifier> <UniqueIdentifier>{b6175f9a-7d46-4b57-877f-f58b0b3bba89}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="1. Modules\ripple_client">
<UniqueIdentifier>{97c96b68-70fd-4679-89fc-c1c8c87c265e}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\cpp\database\sqlite3.c"> <ClCompile Include="src\cpp\database\sqlite3.c">
@@ -469,10 +469,10 @@
<Filter>1. Modules\ripple_basics</Filter> <Filter>1. Modules\ripple_basics</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="modules\ripple_ledger\ripple_ledger.cpp"> <ClCompile Include="modules\ripple_ledger\ripple_ledger.cpp">
<Filter>1. Modules\ripple_ledger</Filter> <Filter>2. Empty\ripple_ledger</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="modules\ripple_client\ripple_client.cpp"> <ClCompile Include="modules\ripple_client\ripple_client.cpp">
<Filter>2. Empty\ripple_client</Filter> <Filter>1. Modules\ripple_client</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\ChangeTransactor.cpp"> <ClCompile Include="src\cpp\ripple\ChangeTransactor.cpp">
<Filter>1. Modules\ripple_main\_unfactored\transactions</Filter> <Filter>1. Modules\ripple_main\_unfactored\transactions</Filter>
@@ -678,9 +678,6 @@
<ClCompile Include="src\cpp\ripple\Pathfinder.cpp"> <ClCompile Include="src\cpp\ripple\Pathfinder.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter> <Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\PFRequest.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\RippleCalc.cpp"> <ClCompile Include="src\cpp\ripple\RippleCalc.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter> <Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile> </ClCompile>
@@ -840,6 +837,9 @@
<ClCompile Include="src\cpp\ripple\ripple_AcceptedLedger.cpp"> <ClCompile Include="src\cpp\ripple\ripple_AcceptedLedger.cpp">
<Filter>1. Modules\ripple_main\refactored</Filter> <Filter>1. Modules\ripple_main\refactored</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\cpp\ripple\ripple_PathRequest.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="database\sqlite3ext.h"> <ClInclude Include="database\sqlite3ext.h">
@@ -1170,10 +1170,10 @@
<Filter>1. Modules\ripple_basics</Filter> <Filter>1. Modules\ripple_basics</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="modules\ripple_ledger\ripple_ledger.h"> <ClInclude Include="modules\ripple_ledger\ripple_ledger.h">
<Filter>1. Modules\ripple_ledger</Filter> <Filter>2. Empty\ripple_ledger</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="modules\ripple_client\ripple_client.h"> <ClInclude Include="modules\ripple_client\ripple_client.h">
<Filter>2. Empty\ripple_client</Filter> <Filter>1. Modules\ripple_client</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\cpp\ripple\ChangeTransactor.h"> <ClInclude Include="src\cpp\ripple\ChangeTransactor.h">
<Filter>1. Modules\ripple_main\_unfactored\transactions</Filter> <Filter>1. Modules\ripple_main\_unfactored\transactions</Filter>
@@ -1412,9 +1412,6 @@
<ClInclude Include="src\cpp\ripple\Pathfinder.h"> <ClInclude Include="src\cpp\ripple\Pathfinder.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter> <Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\cpp\ripple\PFRequest.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\RippleCalc.h"> <ClInclude Include="src\cpp\ripple\RippleCalc.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter> <Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude> </ClInclude>
@@ -1583,6 +1580,9 @@
<ClInclude Include="src\cpp\ripple\ripple_AcceptedLedger.h"> <ClInclude Include="src\cpp\ripple\ripple_AcceptedLedger.h">
<Filter>1. Modules\ripple_main\refactored</Filter> <Filter>1. Modules\ripple_main\refactored</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\cpp\ripple\ripple_PathRequest.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="SConstruct" /> <None Include="SConstruct" />

View File

@@ -1,24 +1,6 @@
#ifndef __APPLICATION__ #ifndef __APPLICATION__
#define __APPLICATION__ #define __APPLICATION__
#include "leveldb/db.h"
#include <boost/asio.hpp>
#include "../database/database.h"
#include "LedgerMaster.h"
#include "TransactionMaster.h"
#include "Wallet.h"
#include "WSDoor.h"
#include "SNTPClient.h"
#include "RPCHandler.h"
#include "LoadManager.h"
#include "TransactionQueue.h"
#include "OrderBookDB.h"
#include "ripple_DatabaseCon.h"
// VFALCO TODO Fix forward declares required for header dependency loops // VFALCO TODO Fix forward declares required for header dependency loops
class IFeatures; class IFeatures;
class IFeeVote; class IFeeVote;

View File

@@ -39,7 +39,14 @@ public:
LedgerEntrySetEntry(SLE::ref e, LedgerEntryAction a, int s) : mEntry(e), mAction(a), mSeq(s) { ; } LedgerEntrySetEntry(SLE::ref e, LedgerEntryAction a, int s) : mEntry(e), mAction(a), mSeq(s) { ; }
}; };
/** An LES is a LedgerEntrySet.
It's a view into a ledger used while a transaction is processing.
The transaction manipulates the LES rather than the ledger
(because it's cheaper, can be checkpointed, and so on). When the
transaction finishes, the LES is committed into the ledger to make
the modifications. The transaction metadata is built from the LES too.
*/
class LedgerEntrySet : private IS_INSTANCE(LedgerEntrySet) class LedgerEntrySet : private IS_INSTANCE(LedgerEntrySet)
{ {
public: public:

View File

@@ -726,12 +726,13 @@ void LedgerMaster::updatePaths()
mPathFindNewRequest = false; mPathFindNewRequest = false;
} }
PFRequest::updateAll(lastLedger, newOnly); // VFALCO TODO Fix this global variable
PathRequest::updateAll (lastLedger, newOnly);
} while(1); } while(1);
} }
void LedgerMaster::newPFRequest() void LedgerMaster::newPathRequest()
{ {
boost::recursive_mutex::scoped_lock ml(mLock); boost::recursive_mutex::scoped_lock ml(mLock);
mPathFindNewRequest = true; mPathFindNewRequest = true;

View File

@@ -11,7 +11,7 @@
class LedgerMaster class LedgerMaster
{ {
public: public:
typedef FUNCTION_TYPE<void(Ledger::ref)> callback; typedef FUNCTION_TYPE <void(Ledger::ref)> callback;
public: public:
LedgerMaster () LedgerMaster ()
@@ -125,7 +125,7 @@ public:
void checkAccept(uint256 const& hash); void checkAccept(uint256 const& hash);
void checkAccept(uint256 const& hash, uint32 seq); void checkAccept(uint256 const& hash, uint32 seq);
void tryPublish(); void tryPublish();
void newPFRequest(); void newPathRequest();
static bool shouldAcquire(uint32 currentLedgerID, uint32 ledgerHistory, uint32 targetLedger); static bool shouldAcquire(uint32 currentLedgerID, uint32 ledgerHistory, uint32 targetLedger);

View File

@@ -19,7 +19,6 @@
#include "AccountState.h" #include "AccountState.h"
#include "NicknameState.h" #include "NicknameState.h"
#include "Offer.h" #include "Offer.h"
#include "PFRequest.h"
SETUP_LOG (RPCHandler) SETUP_LOG (RPCHandler)
@@ -1325,29 +1324,29 @@ Json::Value RPCHandler::doPathFind(Json::Value jvRequest, int& cost, ScopedLock&
if (sSubCommand == "create") if (sSubCommand == "create")
{ {
mInfoSub->clearPFRequest(); mInfoSub->clearPathRequest();
PFRequest::pointer request = boost::make_shared<PFRequest>(mInfoSub); PathRequest::pointer request = boost::make_shared<PathRequest>(mInfoSub);
Json::Value result = request->doCreate(mNetOps->getClosedLedger(), jvRequest); Json::Value result = request->doCreate(mNetOps->getClosedLedger(), jvRequest);
if (request->isValid()) if (request->isValid())
{ {
mInfoSub->setPFRequest(request); mInfoSub->setPathRequest(request);
theApp->getLedgerMaster().newPFRequest(); theApp->getLedgerMaster().newPathRequest();
} }
return result; return result;
} }
if (sSubCommand == "close") if (sSubCommand == "close")
{ {
PFRequest::pointer request = mInfoSub->getPFRequest(); PathRequest::pointer request = mInfoSub->getPathRequest();
if (!request) if (!request)
return rpcError(rpcNO_PF_REQUEST); return rpcError(rpcNO_PF_REQUEST);
mInfoSub->clearPFRequest(); mInfoSub->clearPathRequest();
return request->doClose(jvRequest); return request->doClose(jvRequest);
} }
if (sSubCommand == "status") if (sSubCommand == "status")
{ {
PFRequest::pointer request = mInfoSub->getPFRequest(); PathRequest::pointer request = mInfoSub->getPathRequest();
if (!request) if (!request)
return rpcNO_PF_REQUEST; return rpcNO_PF_REQUEST;
return request->doStatus(jvRequest); return request->doStatus(jvRequest);

View File

@@ -10,7 +10,7 @@
// code assumes this node is synched (and will continue to do so until // code assumes this node is synched (and will continue to do so until
// there's a functional network. // there's a functional network.
DECLARE_INSTANCE(InfoSub); DECLARE_INSTANCE (InfoSub);
// VFALCO TODO Figure out how to clean up these globals // VFALCO TODO Figure out how to clean up these globals
uint64 InfoSub::sSeq = 0; uint64 InfoSub::sSeq = 0;
@@ -54,17 +54,17 @@ void InfoSub::insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex)
mSubAccountInfo.insert(addr); mSubAccountInfo.insert(addr);
} }
void InfoSub::clearPFRequest() void InfoSub::clearPathRequest()
{ {
mPFRequest.reset(); mPathRequest.reset();
} }
void InfoSub::setPFRequest(const boost::shared_ptr<PFRequest>& req) void InfoSub::setPathRequest(const boost::shared_ptr<PathRequest>& req)
{ {
mPFRequest = req; mPathRequest = req;
} }
const boost::shared_ptr<PFRequest>& InfoSub::getPFRequest() const boost::shared_ptr<PathRequest>& InfoSub::getPathRequest()
{ {
return mPFRequest; return mPathRequest;
} }

View File

@@ -4,11 +4,10 @@
// Operations that clients may wish to perform against the network // Operations that clients may wish to perform against the network
// Master operational handler, server sequencer, network tracker // Master operational handler, server sequencer, network tracker
class PFRequest; class PathRequest;
DEFINE_INSTANCE(InfoSub); DEFINE_INSTANCE(InfoSub);
// VFALCO TODO Move InfoSub to a separate file
class InfoSub : public IS_INSTANCE(InfoSub) class InfoSub : public IS_INSTANCE(InfoSub)
{ {
public: public:
@@ -35,23 +34,24 @@ public:
void insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex); void insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex);
void clearPFRequest(); void clearPathRequest();
void setPFRequest (const boost::shared_ptr<PFRequest>& req); void setPathRequest (const boost::shared_ptr<PathRequest>& req);
boost::shared_ptr <PFRequest> const& getPFRequest (); boost::shared_ptr <PathRequest> const& getPathRequest ();
protected: protected:
// VFALCO TODO make accessor for this member // VFALCO TODO make accessor for this member
boost::mutex mLockInfo; boost::mutex mLockInfo;
private: private:
// VFALCO TODO Move these globals to class instance
static uint64 sSeq; static uint64 sSeq;
static boost::mutex sSeqLock; static boost::mutex sSeqLock;
boost::unordered_set<RippleAddress> mSubAccountInfo; boost::unordered_set <RippleAddress> mSubAccountInfo;
boost::unordered_set<RippleAddress> mSubAccountTransaction; boost::unordered_set <RippleAddress> mSubAccountTransaction;
boost::shared_ptr <PFRequest> mPFRequest; boost::shared_ptr <PathRequest> mPathRequest;
uint64 mSeq; uint64 mSeq;
}; };

View File

@@ -1,35 +1,30 @@
#include "PFRequest.h" SETUP_LOG (PathRequest)
#include "RPCErr.h" // VFALCO TODO Move these globals into a PathRequests collection inteface
#include "Ledger.h" boost::recursive_mutex PathRequest::sLock;
#include "Application.h" std::set <PathRequest::wptr> PathRequest::sRequests;
#include "Pathfinder.h"
#include "RippleCalc.h"
SETUP_LOG (PFRequest) PathRequest::PathRequest (const boost::shared_ptr<InfoSub>& subscriber)
: wpSubscriber (subscriber)
boost::recursive_mutex PFRequest::sLock; , jvStatus (Json::objectValue)
std::set<PFRequest::wptr> PFRequest::sRequests; , bValid (false)
, bNew (true)
PFRequest::PFRequest(const boost::shared_ptr<InfoSub>& subscriber) :
wpSubscriber(subscriber), jvStatus(Json::objectValue), bValid(false), bNew(true)
{ {
;
} }
bool PFRequest::isValid() bool PathRequest::isValid()
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
return bValid; return bValid;
} }
bool PFRequest::isNew() bool PathRequest::isNew()
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
return bNew; return bNew;
} }
bool PFRequest::isValid(Ledger::ref lrLedger) bool PathRequest::isValid(Ledger::ref lrLedger)
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
bValid = raSrcAccount.isSet() && raDstAccount.isSet() && saDstAmount.isPositive(); bValid = raSrcAccount.isSet() && raDstAccount.isSet() && saDstAmount.isPositive();
@@ -74,7 +69,7 @@ bool PFRequest::isValid(Ledger::ref lrLedger)
return bValid; return bValid;
} }
Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value) Json::Value PathRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
{ {
assert(lrLedger->isClosed()); assert(lrLedger->isClosed());
@@ -98,9 +93,9 @@ Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
if (mValid) if (mValid)
{ {
WriteLog (lsINFO, PFRequest) << "Request created: " << raSrcAccount.humanAccountID() << WriteLog (lsINFO, PathRequest) << "Request created: " << raSrcAccount.humanAccountID() <<
" -> " << raDstAccount.humanAccountID(); " -> " << raDstAccount.humanAccountID();
WriteLog (lsINFO, PFRequest) << "Deliver: " << saDstAmount.getFullText(); WriteLog (lsINFO, PathRequest) << "Deliver: " << saDstAmount.getFullText();
boost::recursive_mutex::scoped_lock sl(sLock); boost::recursive_mutex::scoped_lock sl(sLock);
sRequests.insert(shared_from_this()); sRequests.insert(shared_from_this());
@@ -109,7 +104,7 @@ Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
return jvStatus; return jvStatus;
} }
int PFRequest::parseJson(const Json::Value& jvParams, bool complete) int PathRequest::parseJson(const Json::Value& jvParams, bool complete)
{ {
int ret = PFR_PJ_NOCHANGE; int ret = PFR_PJ_NOCHANGE;
@@ -194,19 +189,19 @@ int PFRequest::parseJson(const Json::Value& jvParams, bool complete)
return ret; return ret;
} }
Json::Value PFRequest::doClose(const Json::Value&) Json::Value PathRequest::doClose(const Json::Value&)
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
return jvStatus; return jvStatus;
} }
Json::Value PFRequest::doStatus(const Json::Value&) Json::Value PathRequest::doStatus(const Json::Value&)
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
return jvStatus; return jvStatus;
} }
bool PFRequest::doUpdate(RLCache::ref cache, bool fast) bool PathRequest::doUpdate(RLCache::ref cache, bool fast)
{ {
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
jvStatus = Json::objectValue; jvStatus = Json::objectValue;
@@ -246,13 +241,13 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
{ {
{ {
STAmount test(currIssuer.first, currIssuer.second, 1); STAmount test(currIssuer.first, currIssuer.second, 1);
WriteLog (lsDEBUG, PFRequest) << "Trying to find paths: " << test.getFullText(); WriteLog (lsDEBUG, PathRequest) << "Trying to find paths: " << test.getFullText();
} }
bool valid; bool valid;
STPathSet spsPaths; STPathSet spsPaths;
Pathfinder pf(cache, raSrcAccount, raDstAccount, Pathfinder pf(cache, raSrcAccount, raDstAccount,
currIssuer.first, currIssuer.second, saDstAmount, valid); currIssuer.first, currIssuer.second, saDstAmount, valid);
CondLog (!valid, lsINFO, PFRequest) << "PF request not valid"; CondLog (!valid, lsINFO, PathRequest) << "PF request not valid";
if (valid && pf.findPaths(theConfig.PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths)) if (valid && pf.findPaths(theConfig.PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths))
{ {
LedgerEntrySet lesSandbox(cache->getLedger(), tapNONE); LedgerEntrySet lesSandbox(cache->getLedger(), tapNONE);
@@ -263,7 +258,7 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
currIssuer.second.isNonZero() ? currIssuer.second : currIssuer.second.isNonZero() ? currIssuer.second :
(currIssuer.first.isZero() ? ACCOUNT_XRP : raSrcAccount.getAccountID()), 1); (currIssuer.first.isZero() ? ACCOUNT_XRP : raSrcAccount.getAccountID()), 1);
saMaxAmount.negate(); saMaxAmount.negate();
WriteLog (lsDEBUG, PFRequest) << "Paths found, calling rippleCalc"; WriteLog (lsDEBUG, PathRequest) << "Paths found, calling rippleCalc";
TER terResult = RippleCalc::rippleCalc(lesSandbox, saMaxAmountAct, saDstAmountAct, TER terResult = RippleCalc::rippleCalc(lesSandbox, saMaxAmountAct, saDstAmountAct,
vpsExpanded, saMaxAmount, saDstAmount, raDstAccount.getAccountID(), raSrcAccount.getAccountID(), vpsExpanded, saMaxAmount, saDstAmount, raDstAccount.getAccountID(), raSrcAccount.getAccountID(),
spsPaths, false, false, false, true); spsPaths, false, false, false, true);
@@ -276,19 +271,19 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
} }
else else
{ {
WriteLog (lsINFO, PFRequest) << "rippleCalc returns " << transHuman(terResult); WriteLog (lsINFO, PathRequest) << "rippleCalc returns " << transHuman(terResult);
} }
} }
else else
{ {
WriteLog (lsINFO, PFRequest) << "No paths found"; WriteLog (lsINFO, PathRequest) << "No paths found";
} }
} }
jvStatus["alternatives"] = jvArray; jvStatus["alternatives"] = jvArray;
return true; return true;
} }
void PFRequest::updateAll(Ledger::ref ledger, bool newOnly) void PathRequest::updateAll(Ledger::ref ledger, bool newOnly)
{ {
std::set<wptr> requests; std::set<wptr> requests;
@@ -305,7 +300,7 @@ void PFRequest::updateAll(Ledger::ref ledger, bool newOnly)
BOOST_FOREACH(wref wRequest, requests) BOOST_FOREACH(wref wRequest, requests)
{ {
bool remove = true; bool remove = true;
PFRequest::pointer pRequest = wRequest.lock(); PathRequest::pointer pRequest = wRequest.lock();
if (pRequest && (!newOnly || pRequest->isNew())) if (pRequest && (!newOnly || pRequest->isNew()))
{ {
InfoSub::pointer ipSub = pRequest->wpSubscriber.lock(); InfoSub::pointer ipSub = pRequest->wpSubscriber.lock();

View File

@@ -14,7 +14,6 @@
// A pathfinding request submitted by a client // A pathfinding request submitted by a client
// The request issuer must maintain a strong pointer // The request issuer must maintain a strong pointer
class Ledger;
class InfoSub; class InfoSub;
class STAmount; class STAmount;
class RLCache; class RLCache;
@@ -24,17 +23,18 @@ class RLCache;
#define PFR_PJ_NOCHANGE 0 #define PFR_PJ_NOCHANGE 0
#define PFR_PJ_CHANGE 1 #define PFR_PJ_CHANGE 1
class PFRequest : public boost::enable_shared_from_this<PFRequest> class PathRequest : public boost::enable_shared_from_this<PathRequest>
{ {
public: public:
typedef boost::weak_ptr<PFRequest> wptr; typedef boost::weak_ptr<PathRequest> wptr;
typedef boost::shared_ptr<PFRequest> pointer; typedef boost::shared_ptr<PathRequest> pointer;
typedef const pointer& ref; typedef const pointer& ref;
typedef const wptr& wref; typedef const wptr& wref;
typedef std::pair<uint160, uint160> currIssuer_t; typedef std::pair<uint160, uint160> currIssuer_t;
public: public:
PFRequest(const boost::shared_ptr<InfoSub>& subscriber); // VFALCO TODO Break the cyclic dependency on InfoSub
explicit PathRequest (boost::shared_ptr <InfoSub> const& subscriber);
bool isValid(const boost::shared_ptr<Ledger>&); bool isValid(const boost::shared_ptr<Ledger>&);
bool isValid(); bool isValid();