Rename Wallet to LocalCredentials

This commit is contained in:
Vinnie Falco
2013-06-15 18:01:38 -07:00
parent 8aab3645cb
commit 8a6ce5de68
19 changed files with 123 additions and 126 deletions

View File

@@ -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.

View File

@@ -728,7 +728,7 @@ bool NetworkOPs::checkLastClosedLedger (const std::vector<Peer::pointer>& 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 ();

View File

@@ -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;

View File

@@ -1,67 +0,0 @@
#ifndef __WALLET__
#define __WALLET__
#include <vector>
#include <map>
#include <string>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/shared_ptr.hpp>
#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

View File

@@ -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.

View File

@@ -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;

View File

@@ -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 ();

View File

@@ -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

View File

@@ -28,6 +28,12 @@ public:
};
#endif
/** Calculates payment paths.
The @ref RippleCalc determines the quality of the found paths.
@see RippleCalc
*/
class Pathfinder
{
public:

View File

@@ -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);

View File

@@ -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.

View File

@@ -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";

View File

@@ -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
{

View File

@@ -1,5 +1,5 @@
#ifndef __VERSIONS__
#define __VERSIONS__
#ifndef RIPPLE_VERSION_H
#define RIPPLE_VERSION_H
//
// Versions
//

View File

@@ -9,7 +9,6 @@
#include <openssl/evp.h>
#include "RPC.h"
#include "Version.h"
// Used for logging
struct RPC