diff --git a/modules/ripple_data/protocol/ripple_Protocol.h b/modules/ripple_data/protocol/ripple_Protocol.h index 17f0bc0c98..77a07cb737 100644 --- a/modules/ripple_data/protocol/ripple_Protocol.h +++ b/modules/ripple_data/protocol/ripple_Protocol.h @@ -44,6 +44,7 @@ typedef uint256 LedgerHash; */ // VFALCO TODO pick one. I like Index since its not an abbreviation typedef uint32 LedgerIndex; +// VFALCO NOTE "LedgerSeq" appears in some SQL statement text typedef uint32 LedgerSeq; /** A transaction identifier. diff --git a/modules/ripple_main/ripple_main.cpp b/modules/ripple_main/ripple_main.cpp index 1a1a1688dd..a2526b5b4a 100644 --- a/modules/ripple_main/ripple_main.cpp +++ b/modules/ripple_main/ripple_main.cpp @@ -205,7 +205,7 @@ // ----------- #include "src/cpp/ripple/TransactionMaster.h" -#include "src/cpp/ripple/Wallet.h" +#include "src/cpp/ripple/ripple_LocalCredentials.h" #include "src/cpp/ripple/WSDoor.h" #include "src/cpp/ripple/SNTPClient.h" #include "src/cpp/ripple/RPCHandler.h" @@ -248,7 +248,7 @@ #include "src/cpp/ripple/Transactor.h" #include "src/cpp/ripple/AccountSetTransactor.h" #include "src/cpp/ripple/TrustSetTransactor.h" -#include "src/cpp/ripple/Version.h" +#include "src/cpp/ripple/ripple_Version.h" #include "src/cpp/ripple/WSConnection.h" #include "src/cpp/ripple/WSHandler.h" #include "src/cpp/ripple/WalletAddTransactor.h" @@ -313,8 +313,8 @@ static const uint64 tenTo17m1 = tenTo17 - 1; // Generate DH for SSL connection. static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) { - // VFALCO TODO eliminate this horrendous dependency on theApp and Wallet - return 512 == iKeyLength ? theApp->getWallet ().getDh512 () : theApp->getWallet ().getDh1024 (); + // VFALCO TODO eliminate this horrendous dependency on theApp and LocalCredentials + return 512 == iKeyLength ? theApp->getLocalCredentials ().getDh512 () : theApp->getLocalCredentials ().getDh1024 (); } #include "src/cpp/ripple/ParameterTable.cpp" // no log @@ -354,7 +354,7 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) #if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 3 -#include "src/cpp/ripple/Wallet.cpp" +#include "src/cpp/ripple/ripple_LocalCredentials.cpp" #include "src/cpp/ripple/WalletAddTransactor.cpp" #include "src/cpp/ripple/ripple_HashedObject.cpp" diff --git a/newcoin.vcxproj b/newcoin.vcxproj index b953d3db8d..02a4c2a656 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -1273,12 +1273,6 @@ true true - - true - true - true - true - true true @@ -1309,7 +1303,7 @@ true true - + true true true @@ -1841,14 +1835,13 @@ - - - + + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index c08f466d76..da09fe83b0 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -432,9 +432,6 @@ 1. Modules\ripple_main\_unfactored\transactions - - 1. Modules\ripple_main\_unfactored\transactions - 1. Modules\ripple_main\_unfactored\transactions @@ -516,9 +513,6 @@ 1. Modules\ripple_main\_unfactored\transactions - - 1. Modules\ripple_main\_unfactored\transactions - 2. Empty\ripple_mess @@ -888,6 +882,9 @@ 1. Modules\ripple_data\protocol + + 1. Modules\ripple_main\refactored + @@ -1166,9 +1163,6 @@ 1. Modules\ripple_main\_unfactored\transactions - - 1. Modules\ripple_main\_unfactored\transactions - 1. Modules\ripple_main\_unfactored\transactions @@ -1247,9 +1241,6 @@ 1. Modules\ripple_main\_unfactored\transactions - - 1. Modules\ripple_main\_unfactored\transactions - 2. Empty\ripple_mess @@ -1358,9 +1349,6 @@ 1. Modules\ripple_basics\utility - - 1. Modules\ripple_main\_unfactored\main - 1. Modules\ripple_main\_unfactored\network @@ -1655,6 +1643,12 @@ 1. Modules\ripple_data\protocol + + 1. Modules\ripple_main\refactored + + + 1. Modules\ripple_main\_unfactored\main + diff --git a/src/cpp/ripple/DBInit.cpp b/src/cpp/ripple/DBInit.cpp index c80f3fe5ac..176fda95e0 100644 --- a/src/cpp/ripple/DBInit.cpp +++ b/src/cpp/ripple/DBInit.cpp @@ -97,7 +97,9 @@ const char* RpcDBInit[] = int RpcDBCount = NUMBER (RpcDBInit); -// Wallet database holds local accounts and trusted nodes +// NodeIdentity database holds local accounts and trusted nodes +// VFALCO NOTE but its a table not a database, so...? +// const char* WalletDBInit[] = { // Node identity must be persisted for CAS routing and responsibilities. diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 9c58969508..1a87340810 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -728,7 +728,7 @@ bool NetworkOPs::checkLastClosedLedger (const std::vector& peerLi if (mMode >= omTRACKING) { ++ourVC.nodesUsing; - uint160 ourAddress = theApp->getWallet ().getNodePublic ().getNodeID (); + uint160 ourAddress = theApp->getLocalCredentials ().getNodePublic ().getNodeID (); if (ourAddress > ourVC.highNodeUsing) ourVC.highNodeUsing = ourAddress; @@ -1352,7 +1352,7 @@ Json::Value NetworkOPs::getServerInfo (bool human, bool admin) info["pubkey_validator"] = "none"; } - info["pubkey_node"] = theApp->getWallet ().getNodePublic ().humanNodePublic (); + info["pubkey_node"] = theApp->getLocalCredentials ().getNodePublic ().humanNodePublic (); info["complete_ledgers"] = theApp->getLedgerMaster ().getCompleteLedgers (); diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index ee79804f3a..fdb8144dca 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -662,7 +662,7 @@ Json::Value RPCHandler::doDataDelete (Json::Value jvRequest, int& cost, ScopedLo Json::Value ret = Json::Value (Json::objectValue); - if (theApp->getWallet ().dataDelete (strKey)) + if (theApp->getLocalCredentials ().dataDelete (strKey)) { ret["key"] = strKey; } @@ -691,7 +691,7 @@ Json::Value RPCHandler::doDataFetch (Json::Value jvRequest, int& cost, ScopedLoc ret["key"] = strKey; - if (theApp->getWallet ().dataFetch (strKey, strValue)) + if (theApp->getLocalCredentials ().dataFetch (strKey, strValue)) ret["value"] = strValue; return ret; @@ -714,7 +714,7 @@ Json::Value RPCHandler::doDataStore (Json::Value jvRequest, int& cost, ScopedLoc Json::Value ret = Json::Value (Json::objectValue); - if (theApp->getWallet ().dataStore (strKey, strValue)) + if (theApp->getLocalCredentials ().dataStore (strKey, strValue)) { ret["key"] = strKey; ret["value"] = strValue; diff --git a/src/cpp/ripple/Wallet.h b/src/cpp/ripple/Wallet.h deleted file mode 100644 index d2faa4b6f9..0000000000 --- a/src/cpp/ripple/Wallet.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __WALLET__ -#define __WALLET__ - -#include -#include -#include - -#include -#include -#include - -#include "openssl/ec.h" -#include "openssl/dh.h" - -class Ledger; - -class Wallet -{ -private: - bool nodeIdentityLoad (); - bool nodeIdentityCreate (); - - Wallet (const Wallet&); // no implementation - Wallet& operator= (const Wallet&); // no implementation - -public: - Wallet (); - - // Begin processing. - // - Maintain peer connectivity through validation and peer management. - void start (); - - const RippleAddress& getNodePublic () const - { - return mNodePublicKey; - } - const RippleAddress& getNodePrivate () const - { - return mNodePrivateKey; - } - DH* getDh512 () - { - return DHparams_dup (mDh512); - } - DH* getDh1024 () - { - return DHparams_dup (mDh1024); - } - - // Local persistence of RPC clients - bool dataDelete (const std::string& strKey); - bool dataFetch (const std::string& strKey, std::string& strValue); - bool dataStore (const std::string& strKey, const std::string& strValue); - -private: - boost::recursive_mutex mLock; - - RippleAddress mNodePublicKey; - RippleAddress mNodePrivateKey; - DH* mDh512; - DH* mDh1024; - - uint32 mLedger; // ledger we last synched to -}; - -#endif -// vim:ts=4 diff --git a/src/cpp/ripple/ripple_Application.cpp b/src/cpp/ripple/ripple_Application.cpp index 8b12937047..32c7e1250b 100644 --- a/src/cpp/ripple/ripple_Application.cpp +++ b/src/cpp/ripple/ripple_Application.cpp @@ -16,9 +16,9 @@ public: Application (); ~Application (); - Wallet& getWallet () + LocalCredentials& getLocalCredentials () { - return mWallet ; + return mLocalCredentials ; } NetworkOPs& getOPs () { @@ -185,7 +185,7 @@ private: boost::recursive_mutex mMasterLock; - Wallet mWallet; + LocalCredentials mLocalCredentials; LedgerMaster mLedgerMaster; LedgerAcquireMaster mMasterLedgerAcquire; TransactionMaster mMasterTransaction; @@ -460,9 +460,9 @@ void Application::setup () // // Begin validation and ip maintenance. - // - Wallet maintains local information: including identity and network connection persistence information. + // - LocalCredentials maintains local information: including identity and network connection persistence information. // - mWallet.start (); + mLocalCredentials.start (); // // Set up UNL. diff --git a/src/cpp/ripple/ripple_IApplication.h b/src/cpp/ripple/ripple_IApplication.h index 95573818a4..49dae55bcd 100644 --- a/src/cpp/ripple/ripple_IApplication.h +++ b/src/cpp/ripple/ripple_IApplication.h @@ -31,7 +31,7 @@ class PeerDoor; class SerializedLedgerEntry; class TransactionMaster; class TXQueue; -class Wallet; +class LocalCredentials; class DatabaseCon; @@ -83,7 +83,7 @@ public: virtual PeerDoor& getPeerDoor () = 0; virtual TransactionMaster& getMasterTransaction () = 0; virtual TXQueue& getTxnQueue () = 0; - virtual Wallet& getWallet () = 0; + virtual LocalCredentials& getLocalCredentials () = 0; virtual DatabaseCon* getRpcDB () = 0; virtual DatabaseCon* getTxnDB () = 0; diff --git a/src/cpp/ripple/Wallet.cpp b/src/cpp/ripple/ripple_LocalCredentials.cpp similarity index 91% rename from src/cpp/ripple/Wallet.cpp rename to src/cpp/ripple/ripple_LocalCredentials.cpp index 045287922c..786d9a25d6 100644 --- a/src/cpp/ripple/Wallet.cpp +++ b/src/cpp/ripple/ripple_LocalCredentials.cpp @@ -1,10 +1,10 @@ -Wallet::Wallet () : mDh512 (NULL), mDh1024 (NULL), mLedger (0) +LocalCredentials::LocalCredentials () : mDh512 (NULL), mDh1024 (NULL), mLedger (0) { ; } -void Wallet::start () +void LocalCredentials::start () { // We need our node identity before we begin networking. // - Allows others to identify if they have connected multiple times. @@ -25,7 +25,7 @@ void Wallet::start () } // Retrieve network identity. -bool Wallet::nodeIdentityLoad () +bool LocalCredentials::nodeIdentityLoad () { Database* db = theApp->getWalletDB ()->getDB (); @@ -59,7 +59,7 @@ bool Wallet::nodeIdentityLoad () } // Create and store a network identity. -bool Wallet::nodeIdentityCreate () +bool LocalCredentials::nodeIdentityCreate () { if (!theConfig.QUIET) std::cerr << "NodeIdentity: Creating." << std::endl; @@ -114,7 +114,7 @@ bool Wallet::nodeIdentityCreate () return true; } -bool Wallet::dataDelete (const std::string& strKey) +bool LocalCredentials::dataDelete (const std::string& strKey) { Database* db = theApp->getRpcDB ()->getDB (); @@ -124,7 +124,7 @@ bool Wallet::dataDelete (const std::string& strKey) % sqlEscape (strKey))); } -bool Wallet::dataFetch (const std::string& strKey, std::string& strValue) +bool LocalCredentials::dataFetch (const std::string& strKey, std::string& strValue) { Database* db = theApp->getRpcDB ()->getDB (); @@ -146,7 +146,7 @@ bool Wallet::dataFetch (const std::string& strKey, std::string& strValue) return bSuccess; } -bool Wallet::dataStore (const std::string& strKey, const std::string& strValue) +bool LocalCredentials::dataStore (const std::string& strKey, const std::string& strValue) { Database* db = theApp->getRpcDB ()->getDB (); diff --git a/src/cpp/ripple/ripple_LocalCredentials.h b/src/cpp/ripple/ripple_LocalCredentials.h new file mode 100644 index 0000000000..71201f36e8 --- /dev/null +++ b/src/cpp/ripple/ripple_LocalCredentials.h @@ -0,0 +1,61 @@ +#ifndef RIPPLE_LOCALCREDENTIALS_H +#define RIPPLE_LOCALCREDENTIALS_H + +/** Holds the cryptographic credentials identifying this instance of the server. +*/ +class LocalCredentials // derive from Uncopyable +{ +public: + LocalCredentials (); + + // Begin processing. + // - Maintain peer connectivity through validation and peer management. + void start (); + + RippleAddress const& getNodePublic () const + { + return mNodePublicKey; + } + + RippleAddress const& getNodePrivate () const + { + return mNodePrivateKey; + } + + DH* getDh512 () const + { + return DHparams_dup (mDh512); + } + + DH* getDh1024 () const + { + return DHparams_dup (mDh1024); + } + + // Local persistence of RPC clients + bool dataDelete (std::string const& strKey); + + // VFALCO NOTE why is strValue non-const? + bool dataFetch (std::string const& strKey, std::string& strValue); + bool dataStore (std::string const& strKey, std::string const& strValue); + +private: + LocalCredentials (LocalCredentials const&); // disallowed + LocalCredentials& operator= (const LocalCredentials&); // disallowed + + bool nodeIdentityLoad (); + bool nodeIdentityCreate (); + +private: + boost::recursive_mutex mLock; + + RippleAddress mNodePublicKey; + RippleAddress mNodePrivateKey; + DH* mDh512; + DH* mDh1024; + + LedgerIndex mLedger; // ledger we last synched to +}; + +#endif +// vim:ts=4 diff --git a/src/cpp/ripple/ripple_Pathfinder.h b/src/cpp/ripple/ripple_Pathfinder.h index db5eb0515f..30783112fd 100644 --- a/src/cpp/ripple/ripple_Pathfinder.h +++ b/src/cpp/ripple/ripple_Pathfinder.h @@ -28,6 +28,12 @@ public: }; #endif +/** Calculates payment paths. + + The @ref RippleCalc determines the quality of the found paths. + + @see RippleCalc +*/ class Pathfinder { public: diff --git a/src/cpp/ripple/ripple_Peer.cpp b/src/cpp/ripple/ripple_Peer.cpp index dffaa98c00..727d8f3689 100644 --- a/src/cpp/ripple/ripple_Peer.cpp +++ b/src/cpp/ripple/ripple_Peer.cpp @@ -2160,7 +2160,7 @@ void PeerImp::sendHello () getSessionCookie (strCookie); mCookieHash = Serializer::getSHA512Half (strCookie); - theApp->getWallet ().getNodePrivate ().signNodePrivate (mCookieHash, vchSig); + theApp->getLocalCredentials ().getNodePrivate ().signNodePrivate (mCookieHash, vchSig); ripple::TMHello h; @@ -2168,7 +2168,7 @@ void PeerImp::sendHello () h.set_protoversionmin (MAKE_VERSION_INT (MIN_PROTO_MAJOR, MIN_PROTO_MINOR)); h.set_fullversion (SERVER_VERSION); h.set_nettime (theApp->getOPs ().getNetworkTimeNC ()); - h.set_nodepublic (theApp->getWallet ().getNodePublic ().humanNodePublic ()); + h.set_nodepublic (theApp->getLocalCredentials ().getNodePublic ().humanNodePublic ()); h.set_nodeproof (&vchSig[0], vchSig.size ()); h.set_ipv4port (theConfig.PEER_PORT); h.set_nodeprivate (theConfig.PEER_PRIVATE); diff --git a/src/cpp/ripple/ripple_Peers.cpp b/src/cpp/ripple/ripple_Peers.cpp index 33a9d87ba1..15a88555a4 100644 --- a/src/cpp/ripple/ripple_Peers.cpp +++ b/src/cpp/ripple/ripple_Peers.cpp @@ -494,7 +494,7 @@ bool Peers::peerConnected (Peer::ref peer, const RippleAddress& naPeer, assert (!!peer); - if (naPeer == theApp->getWallet ().getNodePublic ()) + if (naPeer == theApp->getLocalCredentials ().getNodePublic ()) { WriteLog (lsINFO, Peers) << "Pool: Connected: self: " << ADDRESS_SHARED (peer) << ": " << naPeer.humanNodePublic () << " " << strIP << " " << iPort; } @@ -704,7 +704,7 @@ void Peers::peerVerified (Peer::ref peer) //WriteLog (lsINFO, Peers) << str(boost::format("Pool: Scan: connected: %s %s %s (scanned)") % ADDRESS_SHARED(peer) % strIp % iPort); - if (peer->getNodePublic () == theApp->getWallet ().getNodePublic ()) + if (peer->getNodePublic () == theApp->getLocalCredentials ().getNodePublic ()) { // Talking to ourself. We will just back off. This lets us maybe advertise our outside address. diff --git a/src/cpp/ripple/ripple_RippleCalc.cpp b/src/cpp/ripple/ripple_RippleCalc.cpp index f288d9ca15..40a4b6bc26 100644 --- a/src/cpp/ripple/ripple_RippleCalc.cpp +++ b/src/cpp/ripple/ripple_RippleCalc.cpp @@ -353,6 +353,9 @@ TER RippleCalc::calcNodeDeliverRev ( while (saOutAct < saOutReq) // Did not deliver as much as requested. { + // VFALCO TODO Why 40? Give this magic constant a name and document it + // NOTE is the number 40 part of protocol? + // if (++loopCount > 40) { WriteLog (lsFATAL, RippleCalc) << "loop count exceeded"; @@ -634,6 +637,7 @@ TER RippleCalc::calcNodeDeliverFwd ( while (tesSUCCESS == terResult && saInAct + saInFees < saInReq) // Did not spend all inbound deliver funds. { + // VFALCO TODO Why 40? if (++loopCount > 40) { WriteLog (lsWARNING, RippleCalc) << "calcNodeDeliverFwd: max loops cndf"; diff --git a/src/cpp/ripple/ripple_RippleCalc.h b/src/cpp/ripple/ripple_RippleCalc.h index 745f1a7cf3..a788485d73 100644 --- a/src/cpp/ripple/ripple_RippleCalc.h +++ b/src/cpp/ripple/ripple_RippleCalc.h @@ -1,8 +1,12 @@ #ifndef RIPPLE_RIPPLECALC_H #define RIPPLE_RIPPLECALC_H -// VFALCO TODO What's the difference between a RippleCalc versus Pathfinder? -// Or a RippleState versus PathState? +/** Calculate the quality of a payment path. + + The quality is a synonym for price. Specifically, the amount of + input required to produce a given output along a specified path. +*/ +// VFALCO TODO What's the difference between a RippleState versus PathState? // class RippleCalc { diff --git a/src/cpp/ripple/Version.h b/src/cpp/ripple/ripple_Version.h similarity index 94% rename from src/cpp/ripple/Version.h rename to src/cpp/ripple/ripple_Version.h index 36bfff42e1..672a83be3c 100644 --- a/src/cpp/ripple/Version.h +++ b/src/cpp/ripple/ripple_Version.h @@ -1,5 +1,5 @@ -#ifndef __VERSIONS__ -#define __VERSIONS__ +#ifndef RIPPLE_VERSION_H +#define RIPPLE_VERSION_H // // Versions // diff --git a/src/cpp/ripple/rpc.cpp b/src/cpp/ripple/rpc.cpp index 7d70b737d2..9178d91903 100644 --- a/src/cpp/ripple/rpc.cpp +++ b/src/cpp/ripple/rpc.cpp @@ -9,7 +9,6 @@ #include #include "RPC.h" -#include "Version.h" // Used for logging struct RPC