diff --git a/src/cpp/ripple/AcceptedLedger.h b/src/cpp/ripple/AcceptedLedger.h index 04b76097cf..45574d83eb 100644 --- a/src/cpp/ripple/AcceptedLedger.h +++ b/src/cpp/ripple/AcceptedLedger.h @@ -20,16 +20,6 @@ */ class ALTransaction { -protected: - SerializedTransaction::pointer mTxn; - TransactionMetaSet::pointer mMeta; - TER mResult; - std::vector mAffected; - std::vector mRawMeta; - Json::Value mJson; - - void buildJson(); - public: typedef boost::shared_ptr pointer; typedef const pointer& ref; @@ -51,6 +41,16 @@ public: int getIndex() const { return mMeta ? mMeta->getIndex() : 0; } std::string getEscMeta() const; Json::Value getJson() const { return mJson; } + +private: + SerializedTransaction::pointer mTxn; + TransactionMetaSet::pointer mMeta; + TER mResult; + std::vector mAffected; + std::vector mRawMeta; + Json::Value mJson; + + void buildJson(); }; /*============================================================================*/ @@ -66,17 +66,7 @@ public: typedef map_t::value_type value_type; typedef map_t::const_iterator const_iterator; -protected: - Ledger::pointer mLedger; - map_t mMap; - - void insert(ALTransaction::ref); - - static TaggedCache ALCache; - AcceptedLedger(Ledger::ref ledger); - public: - static pointer makeAcceptedLedger(Ledger::ref ledger); static void sweep() { ALCache.sweep(); } @@ -89,6 +79,15 @@ public: static float getCacheHitRate() { return ALCache.getHitRate(); } ALTransaction::pointer getTxn(int) const; + +private: + Ledger::pointer mLedger; + map_t mMap; + + void insert(ALTransaction::ref); + + static TaggedCache ALCache; + AcceptedLedger(Ledger::ref ledger); }; #endif diff --git a/src/cpp/ripple/AccountItems.h b/src/cpp/ripple/AccountItems.h index eea600a761..b49bd15317 100644 --- a/src/cpp/ripple/AccountItems.h +++ b/src/cpp/ripple/AccountItems.h @@ -9,8 +9,6 @@ // class AccountItem { -protected: - SerializedLedgerEntry::pointer mLedgerEntry; public: typedef boost::shared_ptr pointer; typedef const pointer& ref; @@ -27,15 +25,14 @@ public: SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } std::vector getRaw() const; + + // VFALCO: TODO make an accessor for mLedgerEntry so we can change protected to private +protected: + SerializedLedgerEntry::pointer mLedgerEntry; }; class AccountItems { - AccountItem::pointer mOfType; - - std::vector mItems; - void fillItems(const uint160& accountID, Ledger::ref ledger); - public: typedef boost::shared_ptr pointer; @@ -43,6 +40,12 @@ public: std::vector& getItems() { return(mItems); } Json::Value getJson(int); + +private: + AccountItem::pointer mOfType; + + std::vector mItems; + void fillItems(const uint160& accountID, Ledger::ref ledger); }; #endif diff --git a/src/cpp/ripple/AutoSocket.h b/src/cpp/ripple/AutoSocket.h index 54b70efb44..e9dbf5b6b5 100644 --- a/src/cpp/ripple/AutoSocket.h +++ b/src/cpp/ripple/AutoSocket.h @@ -33,12 +33,6 @@ public: typedef boost::system::error_code error_code; typedef boost::function callback; -protected: - socket_ptr mSocket; - bool mSecure; - - std::vector mBuffer; - public: AutoSocket(basio::io_service& s, bassl::context& c) : mSecure(false), mBuffer(4) { @@ -230,6 +224,12 @@ protected: mSocket->async_handshake(ssl_socket::server, cbFunc); } } + +private: + socket_ptr mSocket; + bool mSecure; + + std::vector mBuffer; }; #endif diff --git a/src/cpp/ripple/CallRPC.h b/src/cpp/ripple/CallRPC.h index 0ce9a86303..813193d4fd 100644 --- a/src/cpp/ripple/CallRPC.h +++ b/src/cpp/ripple/CallRPC.h @@ -5,7 +5,10 @@ class RPCParser { -protected: +public: + Json::Value parseCommand(std::string strMethod, Json::Value jvParams); + +private: typedef Json::Value (RPCParser::*parseFuncPtr)(const Json::Value &jvParams); Json::Value parseAccountRaw(const Json::Value& jvParams, bool bPeer); @@ -49,9 +52,6 @@ protected: Json::Value parseWalletAccounts(const Json::Value& jvParams); Json::Value parseWalletPropose(const Json::Value& jvParams); Json::Value parseWalletSeed(const Json::Value& jvParams); - -public: - Json::Value parseCommand(std::string strMethod, Json::Value jvParams); }; extern int commandLineRPC(const std::vector& vCmd); diff --git a/src/cpp/ripple/CanonicalTXSet.h b/src/cpp/ripple/CanonicalTXSet.h index 02a4bf2f27..bde6f3e478 100644 --- a/src/cpp/ripple/CanonicalTXSet.h +++ b/src/cpp/ripple/CanonicalTXSet.h @@ -7,10 +7,6 @@ class CanonicalTXKey { -protected: - uint256 mAccount, mTXid; - uint32 mSeq; - public: CanonicalTXKey(const uint256& account, uint32 seq, const uint256& id) : mAccount(account), mTXid(id), mSeq(seq) { ; } @@ -24,6 +20,10 @@ public: bool operator!=(const CanonicalTXKey& k) const { return mTXid != k.mTXid; } const uint256& getTXID() const { return mTXid; } + +private: + uint256 mAccount, mTXid; + uint32 mSeq; }; class CanonicalTXSet @@ -32,10 +32,6 @@ public: typedef std::map::iterator iterator; typedef std::map::const_iterator const_iterator; -protected: - uint256 mSetHash; - std::map mMap; - public: CanonicalTXSet(const uint256& lclHash) : mSetHash(lclHash) { ; } @@ -55,6 +51,10 @@ public: const_iterator end() const { return mMap.end(); } size_t size() const { return mMap.size(); } bool empty() const { return mMap.empty(); } + +private: + uint256 mSetHash; + std::map mMap; }; #endif diff --git a/src/cpp/ripple/ChangeTransactor.h b/src/cpp/ripple/ChangeTransactor.h index 28f3a1947a..061ac30a5c 100644 --- a/src/cpp/ripple/ChangeTransactor.h +++ b/src/cpp/ripple/ChangeTransactor.h @@ -2,13 +2,6 @@ class ChangeTransactor : public Transactor { -protected: - - TER applyFeature(); - TER applyFee(); - - bool mustHaveValidAccount() { return false; } - public: ChangeTransactor(const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine *engine) : Transactor(txn, params, engine) @@ -19,6 +12,13 @@ public: TER checkSeq(); TER payFee(); TER preCheck(); + +private: + TER applyFeature(); + TER applyFee(); + + // VFALCO: TODO, Can this be removed? + bool mustHaveValidAccount() { return false; } }; // vim:ts=4 diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp index 9286e4e2ef..1d953c95c1 100644 --- a/src/cpp/ripple/FeatureTable.cpp +++ b/src/cpp/ripple/FeatureTable.cpp @@ -389,11 +389,6 @@ Json::Value FeatureTable::getJson(const uint256& feature) template class VotableInteger { -protected: - INT mCurrent; // The current setting - INT mTarget; // The setting we want - std::map mVoteMap; - public: VotableInteger(INT current, INT target) : mCurrent(current), mTarget(target) { @@ -435,6 +430,11 @@ public: return ourVote; } + +private: + INT mCurrent; // The current setting + INT mTarget; // The setting we want + std::map mVoteMap; }; // vim:ts=4 diff --git a/src/cpp/ripple/FeatureTable.h b/src/cpp/ripple/FeatureTable.h index a7b12aec9a..b55a98b551 100644 --- a/src/cpp/ripple/FeatureTable.h +++ b/src/cpp/ripple/FeatureTable.h @@ -45,7 +45,6 @@ public: void setFriendlyName(const std::string& n) { mFriendlyName = n; } }; - class FeatureTable { protected: diff --git a/src/cpp/ripple/HTTPRequest.h b/src/cpp/ripple/HTTPRequest.h index a9d1fae6a8..952afba3ff 100644 --- a/src/cpp/ripple/HTTPRequest.h +++ b/src/cpp/ripple/HTTPRequest.h @@ -17,26 +17,6 @@ enum HTTPRequestAction class HTTPRequest { // an HTTP request we are handling from a client -protected: - - enum state - { - await_request, // We are waiting for the request line - await_header, // We are waiting for request headers - getting_body, // We are waiting for the body - do_request, // We are waiting for the request to complete - }; - - state eState; - std::string sRequest; // VERB URL PROTO - std::string sRequestBody; - std::string sAuthorization; - - std::map mHeaders; - - int iDataSize; - bool bShouldClose; - public: HTTPRequest() : eState(await_request), iDataSize(0), bShouldClose(true) { ; } @@ -56,6 +36,25 @@ public: HTTPRequestAction requestDone(bool forceClose); // call after reply is sent int getDataSize() { return iDataSize; } + +private: + enum state + { + await_request, // We are waiting for the request line + await_header, // We are waiting for request headers + getting_body, // We are waiting for the body + do_request, // We are waiting for the request to complete + }; + + state eState; + std::string sRequest; // VERB URL PROTO + std::string sRequestBody; + std::string sAuthorization; + + std::map mHeaders; + + int iDataSize; + bool bShouldClose; }; #endif diff --git a/src/cpp/ripple/HashedObject.h b/src/cpp/ripple/HashedObject.h index cf8957d268..52500bd6f9 100644 --- a/src/cpp/ripple/HashedObject.h +++ b/src/cpp/ripple/HashedObject.h @@ -58,21 +58,7 @@ public: class HashedObjectStore { -protected: - TaggedCache mCache; - KeyCache mNegativeCache; - - boost::mutex mWriteMutex; - boost::condition_variable mWriteCondition; - int mWriteGeneration; - int mWriteLoad; - - std::vector< boost::shared_ptr > mWriteSet; - bool mWritePending; - bool mLevelDB, mEphemeralDB; - public: - HashedObjectStore(int cacheSize, int cacheAge); bool isLevelDB() { return mLevelDB; } @@ -111,6 +97,20 @@ public: int getWriteLoad(); int import(const std::string& fileName); + +private: + TaggedCache mCache; + KeyCache mNegativeCache; + + boost::mutex mWriteMutex; + boost::condition_variable mWriteCondition; + int mWriteGeneration; + int mWriteLoad; + + std::vector< boost::shared_ptr > mWriteSet; + bool mWritePending; + bool mLevelDB; + bool mEphemeralDB; }; #endif diff --git a/src/cpp/ripple/JobQueue.h b/src/cpp/ripple/JobQueue.h index fbce3d8cb2..a855e32690 100644 --- a/src/cpp/ripple/JobQueue.h +++ b/src/cpp/ripple/JobQueue.h @@ -51,13 +51,6 @@ enum JobType class Job { -protected: - JobType mType; - uint64 mJobIndex; - FUNCTION_TYPE mJob; - LoadEvent::pointer mLoadMonitor; - std::string mName; - public: Job() : mType(jtINVALID), mJobIndex(0) { ; } @@ -81,10 +74,44 @@ public: bool operator>=(const Job& j) const; static const char* toString(JobType); + +protected: + JobType mType; + uint64 mJobIndex; + FUNCTION_TYPE mJob; + LoadEvent::pointer mLoadMonitor; + std::string mName; }; class JobQueue { +public: + + JobQueue(boost::asio::io_service&); + + void addJob(JobType type, const std::string& name, const FUNCTION_TYPE& job); + + int getJobCount(JobType t); // Jobs waiting at this priority + int getJobCountTotal(JobType t); // Jobs waiting plus running at this priority + int getJobCountGE(JobType t); // All waiting jobs at or greater than this priority + std::vector< std::pair > > getJobCounts(); // jobs waiting, threads doing + + void shutdown(); + void setThreadCount(int c = 0); + + LoadEvent::pointer getLoadEvent(JobType t, const std::string& name) + { + return boost::make_shared(boost::ref(mJobLoads[t]), name, true); + } + + LoadEvent::autoptr getLoadEventAP(JobType t, const std::string& name) + { + return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], name, true)); + } + + int isOverloaded(); + Json::Value getJson(int c = 0); + protected: boost::mutex mJobLock; boost::condition_variable mJobCond; @@ -104,28 +131,6 @@ protected: void threadEntry(); void IOThread(boost::mutex::scoped_lock&); - -public: - - JobQueue(boost::asio::io_service&); - - void addJob(JobType type, const std::string& name, const FUNCTION_TYPE& job); - - int getJobCount(JobType t); // Jobs waiting at this priority - int getJobCountTotal(JobType t); // Jobs waiting plus running at this priority - int getJobCountGE(JobType t); // All waiting jobs at or greater than this priority - std::vector< std::pair > > getJobCounts(); // jobs waiting, threads doing - - void shutdown(); - void setThreadCount(int c = 0); - - LoadEvent::pointer getLoadEvent(JobType t, const std::string& name) - { return boost::make_shared(boost::ref(mJobLoads[t]), name, true); } - LoadEvent::autoptr getLoadEventAP(JobType t, const std::string& name) - { return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], name, true)); } - - int isOverloaded(); - Json::Value getJson(int c = 0); }; #endif diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h index db56195efb..510f927b2e 100644 --- a/src/cpp/ripple/Ledger.h +++ b/src/cpp/ripple/Ledger.h @@ -43,6 +43,7 @@ class SqliteStatement; class Ledger : public boost::enable_shared_from_this, public IS_INSTANCE(Ledger) { // The basic Ledger structure, can be opened, closed, or synching + // VFALCO: TODO, eliminate the need for friends friend class TransactionEngine; friend class Transactor; public: @@ -67,39 +68,6 @@ public: // ledger close flags static const uint32 sLCF_NoConsensusTime = 1; -private: - - uint256 mHash, mParentHash, mTransHash, mAccountHash; - uint64 mTotCoins; - uint32 mLedgerSeq; - uint32 mCloseTime; // when this ledger closed - uint32 mParentCloseTime; // when the previous ledger closed - int mCloseResolution; // the resolution for this ledger close time (2-120 seconds) - uint32 mCloseFlags; // flags indicating how this ledger close took place - bool mClosed, mValidHash, mAccepted, mImmutable; - - uint32 mReferenceFeeUnits; // Fee units for the reference transaction - uint32 mReserveBase, mReserveIncrement; // Reserve basse and increment in fee units - uint64 mBaseFee; // Ripple cost of the reference transaction - - SHAMap::pointer mTransactionMap, mAccountStateMap; - - mutable boost::recursive_mutex mLock; - - Ledger(const Ledger&); // no implementation - Ledger& operator=(const Ledger&); // no implementation - -protected: - SLE::pointer getASNode(LedgerStateParms& parms, const uint256& nodeID, LedgerEntryType let); - - // returned SLE is immutable - SLE::pointer getASNodeI(const uint256& nodeID, LedgerEntryType let); - - void saveAcceptedLedger(Job&, bool fromConsensus); - - void updateFees(); - void zeroFees(); - public: Ledger(const RippleAddress& masterID, uint64 startAmount); // used for the starting bootstrap ledger @@ -358,6 +326,39 @@ public: bool walkLedger(); bool assertSane(); + +protected: + SLE::pointer getASNode(LedgerStateParms& parms, const uint256& nodeID, LedgerEntryType let); + + // returned SLE is immutable + SLE::pointer getASNodeI(const uint256& nodeID, LedgerEntryType let); + + void saveAcceptedLedger(Job&, bool fromConsensus); + + void updateFees(); + void zeroFees(); + +private: + uint256 mHash, mParentHash, mTransHash, mAccountHash; + uint64 mTotCoins; + uint32 mLedgerSeq; + uint32 mCloseTime; // when this ledger closed + uint32 mParentCloseTime; // when the previous ledger closed + int mCloseResolution; // the resolution for this ledger close time (2-120 seconds) + uint32 mCloseFlags; // flags indicating how this ledger close took place + bool mClosed, mValidHash, mAccepted, mImmutable; + + uint32 mReferenceFeeUnits; // Fee units for the reference transaction + uint32 mReserveBase, mReserveIncrement; // Reserve basse and increment in fee units + uint64 mBaseFee; // Ripple cost of the reference transaction + + SHAMap::pointer mTransactionMap, mAccountStateMap; + + mutable boost::recursive_mutex mLock; + + // VFALCO: TODO, derive this from beast::Uncopyable + Ledger(const Ledger&); // no implementation + Ledger& operator=(const Ledger&); // no implementation }; inline LedgerStateParms operator|(const LedgerStateParms& l1, const LedgerStateParms& l2) diff --git a/src/cpp/ripple/LedgerAcquire.h b/src/cpp/ripple/LedgerAcquire.h index 5432b5d778..88b96172fb 100644 --- a/src/cpp/ripple/LedgerAcquire.h +++ b/src/cpp/ripple/LedgerAcquire.h @@ -25,22 +25,6 @@ DEFINE_INSTANCE(LedgerAcquire); class PeerSet { -protected: - uint256 mHash; - int mTimerInterval, mTimeouts; - bool mComplete, mFailed, mProgress, mAggressive; - int mLastAction; - - boost::recursive_mutex mLock; - boost::asio::deadline_timer mTimer; - boost::unordered_map mPeers; - - PeerSet(const uint256& hash, int interval); - virtual ~PeerSet() { ; } - - void sendRequest(const ripple::TMGetLedger& message); - void sendRequest(const ripple::TMGetLedger& message, Peer::ref peer); - public: const uint256& getHash() const { return mHash; } bool isComplete() const { return mComplete; } @@ -70,6 +54,22 @@ protected: void setFailed() { mFailed = true; } void invokeOnTimer(); +protected: + uint256 mHash; + int mTimerInterval, mTimeouts; + bool mComplete, mFailed, mProgress, mAggressive; + int mLastAction; + + boost::recursive_mutex mLock; + boost::asio::deadline_timer mTimer; + boost::unordered_map mPeers; + + PeerSet(const uint256& hash, int interval); + virtual ~PeerSet() { ; } + + void sendRequest(const ripple::TMGetLedger& message); + void sendRequest(const ripple::TMGetLedger& message, Peer::ref peer); + private: static void TimerEntry(boost::weak_ptr, const boost::system::error_code& result); static void TimerJobEntry(Job&, boost::shared_ptr); diff --git a/src/cpp/ripple/LedgerConsensus.h b/src/cpp/ripple/LedgerConsensus.h index 5e33d186a3..c1d8acd4c6 100644 --- a/src/cpp/ripple/LedgerConsensus.h +++ b/src/cpp/ripple/LedgerConsensus.h @@ -19,9 +19,12 @@ DEFINE_INSTANCE(LedgerConsensus); DEFINE_INSTANCE(TransactionAcquire); -class TransactionAcquire : - private IS_INSTANCE(TransactionAcquire), public PeerSet, public boost::enable_shared_from_this -{ // A transaction set we are trying to acquire +// A transaction set we are trying to acquire +class TransactionAcquire + : private IS_INSTANCE (TransactionAcquire) + , public PeerSet + , public boost::enable_shared_from_this +{ public: typedef boost::shared_ptr pointer; @@ -37,7 +40,6 @@ protected: boost::weak_ptr pmDowncast(); public: - TransactionAcquire(const uint256& hash); virtual ~TransactionAcquire() { ; } diff --git a/src/cpp/ripple/LedgerEntrySet.h b/src/cpp/ripple/LedgerEntrySet.h index 51ffbadba8..be99ac15e1 100644 --- a/src/cpp/ripple/LedgerEntrySet.h +++ b/src/cpp/ripple/LedgerEntrySet.h @@ -49,30 +49,7 @@ public: class LedgerEntrySet : private IS_INSTANCE(LedgerEntrySet) { -protected: - Ledger::pointer mLedger; - std::map mEntries; // cannot be unordered! - TransactionMetaSet mSet; - TransactionEngineParams mParams; - int mSeq; - bool mImmutable; - - LedgerEntrySet(Ledger::ref ledger, const std::map &e, - const TransactionMetaSet& s, int m) : - mLedger(ledger), mEntries(e), mSet(s), mParams(tapNONE), mSeq(m), mImmutable(false) { ; } - - SLE::pointer getForMod(const uint256& node, Ledger::ref ledger, - boost::unordered_map& newMods); - - bool threadTx(const RippleAddress& threadTo, Ledger::ref ledger, - boost::unordered_map& newMods); - - bool threadTx(SLE::ref threadTo, Ledger::ref ledger, boost::unordered_map& newMods); - - bool threadOwners(SLE::ref node, Ledger::ref ledger, boost::unordered_map& newMods); - public: - LedgerEntrySet(Ledger::ref ledger, TransactionEngineParams tep, bool immutable = false) : mLedger(ledger), mParams(tep), mSeq(0), mImmutable(immutable) { ; } @@ -182,6 +159,28 @@ public: std::map::iterator end() { return mEntries.end(); } static bool intersect(const LedgerEntrySet& lesLeft, const LedgerEntrySet& lesRight); + +private: + Ledger::pointer mLedger; + std::map mEntries; // cannot be unordered! + TransactionMetaSet mSet; + TransactionEngineParams mParams; + int mSeq; + bool mImmutable; + + LedgerEntrySet(Ledger::ref ledger, const std::map &e, + const TransactionMetaSet& s, int m) : + mLedger(ledger), mEntries(e), mSet(s), mParams(tapNONE), mSeq(m), mImmutable(false) { ; } + + SLE::pointer getForMod(const uint256& node, Ledger::ref ledger, + boost::unordered_map& newMods); + + bool threadTx(const RippleAddress& threadTo, Ledger::ref ledger, + boost::unordered_map& newMods); + + bool threadTx(SLE::ref threadTo, Ledger::ref ledger, boost::unordered_map& newMods); + + bool threadOwners(SLE::ref node, Ledger::ref ledger, boost::unordered_map& newMods); }; inline LedgerEntrySet::iterator range_begin(LedgerEntrySet& x) { return x.begin(); } diff --git a/src/cpp/ripple/LedgerMaster.h b/src/cpp/ripple/LedgerMaster.h index 9ff16a5410..90e4ee7d0c 100644 --- a/src/cpp/ripple/LedgerMaster.h +++ b/src/cpp/ripple/LedgerMaster.h @@ -18,49 +18,7 @@ class LedgerMaster public: typedef FUNCTION_TYPE callback; -protected: - boost::recursive_mutex mLock; - - TransactionEngine mEngine; - - Ledger::pointer mCurrentLedger; // The ledger we are currently processiong - Ledger::pointer mCurrentSnapshot; // Snapshot of the current ledger - Ledger::pointer mFinalizedLedger; // The ledger that most recently closed - Ledger::pointer mValidLedger; // The highest-sequence ledger we have fully accepted - Ledger::pointer mPubLedger; // The last ledger we have published - - LedgerHistory mLedgerHistory; - - CanonicalTXSet mHeldTransactions; - - RangeSet mCompleteLedgers; - LedgerAcquire::pointer mMissingLedger; - uint32 mMissingSeq; - - int mMinValidations; // The minimum validations to publish a ledger - uint256 mLastValidateHash; - uint32 mLastValidateSeq; - std::list mOnValidate; // Called when a ledger has enough validations - - std::list mPubLedgers; // List of ledgers to publish - bool mPubThread; // Publish thread is running - - bool mPathFindThread; // Pathfind thread is running - bool mPathFindNewLedger; - bool mPathFindNewRequest; - - void applyFutureTransactions(uint32 ledgerIndex); - bool isValidTransaction(Transaction::ref trans); - bool isTransactionOnFutureList(Transaction::ref trans); - - bool acquireMissingLedger(Ledger::ref from, const uint256& ledgerHash, uint32 ledgerSeq); - void asyncAccept(Ledger::pointer); - void missingAcquireComplete(LedgerAcquire::pointer); - void pubThread(); - void updatePaths(); - public: - LedgerMaster() : mHeldTransactions(uint256()), mMissingSeq(0), mMinValidations(0), mLastValidateSeq(0), mPubThread(false), mPathFindThread(false), mPathFindNewLedger(false), mPathFindNewRequest(false) @@ -168,6 +126,47 @@ public: void newPFRequest(); static bool shouldAcquire(uint32 currentLedgerID, uint32 ledgerHistory, uint32 targetLedger); + +private: + void applyFutureTransactions(uint32 ledgerIndex); + bool isValidTransaction(Transaction::ref trans); + bool isTransactionOnFutureList(Transaction::ref trans); + + bool acquireMissingLedger(Ledger::ref from, const uint256& ledgerHash, uint32 ledgerSeq); + void asyncAccept(Ledger::pointer); + void missingAcquireComplete(LedgerAcquire::pointer); + void pubThread(); + void updatePaths(); + + boost::recursive_mutex mLock; + + TransactionEngine mEngine; + + Ledger::pointer mCurrentLedger; // The ledger we are currently processiong + Ledger::pointer mCurrentSnapshot; // Snapshot of the current ledger + Ledger::pointer mFinalizedLedger; // The ledger that most recently closed + Ledger::pointer mValidLedger; // The highest-sequence ledger we have fully accepted + Ledger::pointer mPubLedger; // The last ledger we have published + + LedgerHistory mLedgerHistory; + + CanonicalTXSet mHeldTransactions; + + RangeSet mCompleteLedgers; + LedgerAcquire::pointer mMissingLedger; + uint32 mMissingSeq; + + int mMinValidations; // The minimum validations to publish a ledger + uint256 mLastValidateHash; + uint32 mLastValidateSeq; + std::list mOnValidate; // Called when a ledger has enough validations + + std::list mPubLedgers; // List of ledgers to publish + bool mPubThread; // Publish thread is running + + bool mPathFindThread; // Pathfind thread is running + bool mPathFindNewLedger; + bool mPathFindNewRequest; }; #endif diff --git a/src/cpp/ripple/LedgerProposal.h b/src/cpp/ripple/LedgerProposal.h index 10991c50c2..7c4387da05 100644 --- a/src/cpp/ripple/LedgerProposal.h +++ b/src/cpp/ripple/LedgerProposal.h @@ -11,18 +11,6 @@ DEFINE_INSTANCE(LedgerProposal); class LedgerProposal : private IS_INSTANCE(LedgerProposal) { -protected: - - uint256 mPreviousLedger, mCurrentHash, mSuppression; - uint32 mCloseTime, mProposeSeq; - - uint160 mPeerID; - RippleAddress mPublicKey; - RippleAddress mPrivateKey; // If ours - - std::string mSignature; // set only if needed - boost::posix_time::ptime mTime; - public: static const uint32 seqLeave = 0xffffffff; // leaving the consensus process @@ -67,6 +55,17 @@ public: bool changePosition(const uint256& newPosition, uint32 newCloseTime); void bowOut(); Json::Value getJson() const; + +private: + uint256 mPreviousLedger, mCurrentHash, mSuppression; + uint32 mCloseTime, mProposeSeq; + + uint160 mPeerID; + RippleAddress mPublicKey; + RippleAddress mPrivateKey; // If ours + + std::string mSignature; // set only if needed + boost::posix_time::ptime mTime; }; #endif diff --git a/src/cpp/ripple/LoadManager.h b/src/cpp/ripple/LoadManager.h index 36963f96aa..375648f67c 100644 --- a/src/cpp/ripple/LoadManager.h +++ b/src/cpp/ripple/LoadManager.h @@ -46,22 +46,15 @@ public: class LoadSource { // a single endpoint that can impose load +private: + // VFALCO: Make this not a friend friend class LoadManager; public: - // load source flags static const int lsfPrivileged = 1; static const int lsfOutbound = 2; // outbound connection -protected: - std::string mName; - int mBalance; - int mFlags; - int mLastUpdate; - int mLastWarning; - bool mLogged; - public: LoadSource(bool admin) : mBalance(0) @@ -94,39 +87,19 @@ public: void setOutbound() { mFlags |= lsfOutbound; } bool isOutbound() const { return (mFlags & lsfOutbound) != 0; } + +private: + std::string mName; + int mBalance; + int mFlags; + int mLastUpdate; + int mLastWarning; + bool mLogged; }; class LoadManager { // a collection of load sources -protected: - - int mCreditRate; // credits gained/lost per second - int mCreditLimit; // the most credits a source can have - int mDebitWarn; // when a source drops below this, we warn - int mDebitLimit; // when a source drops below this, we cut it off (should be negative) - - bool mShutdown; - bool mArmed; - - /* - int mSpace1[4]; // We want mUptime to have its own cache line - int mUptime; - int mSpace2[4]; - */ - - int mDeadLock; // Detect server deadlocks - - mutable boost::mutex mLock; - - void canonicalize(LoadSource&, int upTime) const; - - std::vector mCosts; - - void addLoadCost(const LoadCost& c) { mCosts[static_cast(c.mType)] = c; } - - void threadEntry(); - public: LoadManager(int creditRate = 100, int creditLimit = 500, int debitWarn = -500, int debitLimit = -1000); @@ -153,6 +126,33 @@ public: int getCost(LoadType t) { return mCosts[static_cast(t)].mCost; } void noDeadLock(); void arm() { mArmed = true; } + +private: + int mCreditRate; // credits gained/lost per second + int mCreditLimit; // the most credits a source can have + int mDebitWarn; // when a source drops below this, we warn + int mDebitLimit; // when a source drops below this, we cut it off (should be negative) + + bool mShutdown; + bool mArmed; + + /* + int mSpace1[4]; // We want mUptime to have its own cache line + int mUptime; + int mSpace2[4]; + */ + + int mDeadLock; // Detect server deadlocks + + mutable boost::mutex mLock; + + void canonicalize(LoadSource&, int upTime) const; + + std::vector mCosts; + + void addLoadCost(const LoadCost& c) { mCosts[static_cast(c.mType)] = c; } + + void threadEntry(); }; #endif diff --git a/src/cpp/ripple/LoadMonitor.h b/src/cpp/ripple/LoadMonitor.h index 3c3f44a7ee..944f835c67 100644 --- a/src/cpp/ripple/LoadMonitor.h +++ b/src/cpp/ripple/LoadMonitor.h @@ -11,18 +11,6 @@ class LoadMonitor { -protected: - uint64 mCounts; - uint64 mLatencyEvents; - uint64 mLatencyMSAvg; - uint64 mLatencyMSPeak; - uint64 mTargetLatencyAvg; - uint64 mTargetLatencyPk; - int mLastUpdate; - boost::mutex mLock; - - void update(); - public: LoadMonitor() : mCounts(0) @@ -53,6 +41,18 @@ public: void getCountAndLatency(uint64& count, uint64& latencyAvg, uint64& latencyPeak, bool& isOver); bool isOver(); + +private: + void update(); + + uint64 mCounts; + uint64 mLatencyEvents; + uint64 mLatencyMSAvg; + uint64 mLatencyMSPeak; + uint64 mTargetLatencyAvg; + uint64 mTargetLatencyPk; + int mLastUpdate; + boost::mutex mLock; }; class LoadEvent @@ -61,12 +61,6 @@ public: typedef boost::shared_ptr pointer; typedef UPTR_T autoptr; -protected: - LoadMonitor& mMonitor; - bool mRunning; - std::string mName; - boost::posix_time::ptime mStartTime; - public: LoadEvent(LoadMonitor& monitor, const std::string& name, bool shouldStart) : mMonitor(monitor), mRunning(false), mName(name) @@ -100,6 +94,12 @@ public: mMonitor.addCountAndLatency(mName, static_cast((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds())); } + +private: + LoadMonitor& mMonitor; + bool mRunning; + std::string mName; + boost::posix_time::ptime mStartTime; }; #endif diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index 592573969d..ea08c23879 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -25,19 +25,9 @@ class PFRequest; DEFINE_INSTANCE(InfoSub); +// VFALCO: TODO Move InfoSub to a separate file class InfoSub : public IS_INSTANCE(InfoSub) { -protected: - boost::unordered_set mSubAccountInfo; - boost::unordered_set mSubAccountTransaction; - boost::shared_ptr mPFRequest; - - boost::mutex mLockInfo; - - uint64 mSeq; - static uint64 sSeq; - static boost::mutex sSeqLock; - public: typedef boost::shared_ptr pointer; typedef boost::weak_ptr wptr; @@ -83,6 +73,19 @@ public: { return mPFRequest; } + +protected: + // VFALCO: TODO, make accessor for this member + boost::mutex mLockInfo; + +private: + boost::unordered_set mSubAccountInfo; + boost::unordered_set mSubAccountTransaction; + boost::shared_ptr mPFRequest; + + uint64 mSeq; + static uint64 sSeq; + static boost::mutex sSeqLock; }; class NetworkOPs @@ -105,69 +108,6 @@ public: typedef boost::unordered_map subMapType; -protected: - typedef boost::unordered_map subInfoMapType; - typedef boost::unordered_map::value_type subInfoMapValue; - typedef boost::unordered_map::iterator subInfoMapIterator; - - typedef boost::unordered_map subRpcMapType; - - OperatingMode mMode; - bool mNeedNetworkLedger; - bool mProposing, mValidating; - bool mFeatureBlocked; - boost::posix_time::ptime mConnectTime; - boost::asio::deadline_timer mNetTimer; - boost::shared_ptr mConsensus; - boost::unordered_map > mStoredProposals; - - LedgerMaster* mLedgerMaster; - LedgerAcquire::pointer mAcquiringLedger; - - int mCloseTimeOffset; - - // last ledger close - int mLastCloseProposers, mLastCloseConvergeTime; - uint256 mLastCloseHash; - uint32 mLastCloseTime; - uint32 mLastValidationTime; - SerializedValidation::pointer mLastValidation; - - // Recent positions taken - std::map > mRecentPositions; - - // XXX Split into more locks. - boost::recursive_mutex mMonitorLock; - subInfoMapType mSubAccount; - subInfoMapType mSubRTAccount; - - subRpcMapType mRpcSubMap; - - subMapType mSubLedger; // accepted ledgers - subMapType mSubServer; // when server changes connectivity state - subMapType mSubTransactions; // all accepted transactions - subMapType mSubRTTransactions; // all proposed and accepted transactions - - TaggedCache< uint256, std::vector, UptimeTimerAdapter > mFetchPack; - uint32 mLastFetchPack; - uint32 mFetchSeq; - - uint32 mLastLoadBase; - uint32 mLastLoadFactor; - - void setMode(OperatingMode); - - Json::Value transJson(const SerializedTransaction& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent); - bool haveConsensusObject(); - - Json::Value pubBootstrapAccountInfo(Ledger::ref lpAccepted, const RippleAddress& naAccountID); - - void pubValidatedTransaction(Ledger::ref alAccepted, const ALTransaction& alTransaction); - void pubAccountTransaction(Ledger::ref lpCurrent, const ALTransaction& alTransaction, bool isAccepted); - - void pubServer(); - public: NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster); @@ -259,7 +199,16 @@ public: // Book functions // - void getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPaysCurrencyID, const uint160& uTakerPaysIssuerID, const uint160& uTakerGetsCurrencyID, const uint160& uTakerGetsIssuerID, const uint160& uTakerID, const bool bProof, const unsigned int iLimit, const Json::Value& jvMarker, Json::Value& jvResult); + void getBookPage (Ledger::pointer lpLedger, + const uint160& uTakerPaysCurrencyID, + const uint160& uTakerPaysIssuerID, + const uint160& uTakerGetsCurrencyID, + const uint160& uTakerGetsIssuerID, + const uint160& uTakerID, + const bool bProof, + const unsigned int iLimit, + const Json::Value& jvMarker, + Json::Value& jvResult); // raw object operations bool findRawLedger(const uint256& ledgerHash, std::vector& rawLedger); @@ -375,6 +324,69 @@ public: InfoSub::pointer findRpcSub(const std::string& strUrl); InfoSub::pointer addRpcSub(const std::string& strUrl, InfoSub::ref rspEntry); + +private: + typedef boost::unordered_map subInfoMapType; + typedef boost::unordered_map::value_type subInfoMapValue; + typedef boost::unordered_map::iterator subInfoMapIterator; + + typedef boost::unordered_map subRpcMapType; + + OperatingMode mMode; + bool mNeedNetworkLedger; + bool mProposing, mValidating; + bool mFeatureBlocked; + boost::posix_time::ptime mConnectTime; + boost::asio::deadline_timer mNetTimer; + boost::shared_ptr mConsensus; + boost::unordered_map > mStoredProposals; + + LedgerMaster* mLedgerMaster; + LedgerAcquire::pointer mAcquiringLedger; + + int mCloseTimeOffset; + + // last ledger close + int mLastCloseProposers, mLastCloseConvergeTime; + uint256 mLastCloseHash; + uint32 mLastCloseTime; + uint32 mLastValidationTime; + SerializedValidation::pointer mLastValidation; + + // Recent positions taken + std::map > mRecentPositions; + + // XXX Split into more locks. + boost::recursive_mutex mMonitorLock; + subInfoMapType mSubAccount; + subInfoMapType mSubRTAccount; + + subRpcMapType mRpcSubMap; + + subMapType mSubLedger; // accepted ledgers + subMapType mSubServer; // when server changes connectivity state + subMapType mSubTransactions; // all accepted transactions + subMapType mSubRTTransactions; // all proposed and accepted transactions + + TaggedCache< uint256, std::vector, UptimeTimerAdapter > mFetchPack; + uint32 mLastFetchPack; + uint32 mFetchSeq; + + uint32 mLastLoadBase; + uint32 mLastLoadFactor; + + void setMode(OperatingMode); + + Json::Value transJson(const SerializedTransaction& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent); + bool haveConsensusObject(); + + Json::Value pubBootstrapAccountInfo(Ledger::ref lpAccepted, const RippleAddress& naAccountID); + + void pubValidatedTransaction(Ledger::ref alAccepted, const ALTransaction& alTransaction); + void pubAccountTransaction(Ledger::ref lpCurrent, const ALTransaction& alTransaction, bool isAccepted); + + void pubServer(); }; #endif diff --git a/src/cpp/ripple/OfferCreateTransactor.h b/src/cpp/ripple/OfferCreateTransactor.h index 795db826e6..bdce5d8f49 100644 --- a/src/cpp/ripple/OfferCreateTransactor.h +++ b/src/cpp/ripple/OfferCreateTransactor.h @@ -5,7 +5,11 @@ class OfferCreateTransactor : public Transactor { -protected: +public: + OfferCreateTransactor (const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {} + TER doApply(); + +private: bool bValidOffer( SLE::ref sleOfferDir, const uint256& uOffer, @@ -33,10 +37,8 @@ protected: boost::unordered_set usOfferUnfundedFound; // Offers found unfunded. -public: - OfferCreateTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {} - TER doApply(); }; + #endif // vim:ts=4 diff --git a/src/cpp/ripple/PFRequest.h b/src/cpp/ripple/PFRequest.h index 4308f5b2e4..180e25fc4d 100644 --- a/src/cpp/ripple/PFRequest.h +++ b/src/cpp/ripple/PFRequest.h @@ -34,8 +34,23 @@ public: typedef const wptr& wref; typedef std::pair currIssuer_t; +public: + PFRequest(const boost::shared_ptr& subscriber); -protected: + bool isValid(const boost::shared_ptr&); + bool isValid(); + bool isNew(); + Json::Value getStatus(); + + Json::Value doCreate(const boost::shared_ptr&, const Json::Value&); + Json::Value doClose(const Json::Value&); + Json::Value doStatus(const Json::Value&); + + bool doUpdate(const boost::shared_ptr&, bool fast); // update jvStatus + + static void updateAll(const boost::shared_ptr& ledger, bool newOnly); + +private: boost::recursive_mutex mLock; boost::weak_ptr wpSubscriber; // Who this request came from Json::Value jvId; @@ -57,23 +72,6 @@ protected: void setValid(); int parseJson(const Json::Value&, bool complete); - -public: - - PFRequest(const boost::shared_ptr& subscriber); - - bool isValid(const boost::shared_ptr&); - bool isValid(); - bool isNew(); - Json::Value getStatus(); - - Json::Value doCreate(const boost::shared_ptr&, const Json::Value&); - Json::Value doClose(const Json::Value&); - Json::Value doStatus(const Json::Value&); - - bool doUpdate(const boost::shared_ptr&, bool fast); // update jvStatus - - static void updateAll(const boost::shared_ptr& ledger, bool newOnly); }; #endif diff --git a/src/cpp/ripple/ParameterTable.h b/src/cpp/ripple/ParameterTable.h index 34ecf1d08f..7452058746 100644 --- a/src/cpp/ripple/ParameterTable.h +++ b/src/cpp/ripple/ParameterTable.h @@ -13,10 +13,6 @@ public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; -protected: - pointer mParent; - std::string mName; - public: Parameter(Parameter::ref parent, const std::string& name) : mParent(parent), mName(name) { ; } virtual ~Parameter() { ; } @@ -27,13 +23,14 @@ public: virtual bool setValue(const Json::Value& value, Json::Value& error) = 0; Parameter::pointer getShared() { return shared_from_this(); } + +private: + pointer mParent; + std::string mName; }; class ParameterNode : public Parameter { -protected: - std::map mChildren; - public: ParameterNode(Parameter::ref parent, const std::string& name) : Parameter(parent, name) { ; } bool addChildNode(Parameter::ref node); @@ -43,28 +40,31 @@ public: virtual Json::Value getValue(int) const; virtual bool setValue(const Json::Value& value, Json::Value& error); + +private: + std::map mChildren; }; class ParameterString : public Parameter { -protected: - std::string mValue; - public: ParameterString(Parameter::ref parent, const std::string& name, const std::string& value); virtual Json::Value getValue(int) const; virtual bool setValue(const Json::Value& value, Json::Value& error); + +private: + std::string mValue; }; class ParameterInt : public Parameter { -protected: - int mValue; - public: ParameterInt(Parameter::ref parent, const std::string& name, int value); virtual Json::Value getValue(int) const; virtual bool setValue(const Json::Value& value, Json::Value& error); + +private: + int mValue; }; #endif diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index 23946b4516..1e487908ef 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -36,11 +36,6 @@ public: class RLCache { -protected: - boost::mutex mLock; - Ledger::pointer mLedger; - boost::unordered_map mRLMap; - public: typedef boost::shared_ptr pointer; typedef const pointer& ref; @@ -49,10 +44,25 @@ public: Ledger::ref getLedger() { return mLedger; } AccountItems& getRippleLines(const uint160& accountID); + +private: + boost::mutex mLock; + Ledger::pointer mLedger; + boost::unordered_map mRLMap; }; class Pathfinder { +public: + Pathfinder(RLCache::ref cache, + const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, + const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount, bool& bValid); + + bool findPaths(const unsigned int iMaxSteps, const unsigned int iMaxPaths, STPathSet& spsDst); + + bool bDefaultPath(const STPath& spPath); + +private: uint160 mSrcAccountID; uint160 mDstAccountID; STAmount mDstAmount; @@ -82,15 +92,6 @@ class Pathfinder int getPathsOut(const uint160& currency, const uint160& accountID, bool isAuthRequired, bool isDestCurrency, const uint160& dest); - -public: - Pathfinder(RLCache::ref cache, - const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, - const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount, bool& bValid); - - bool findPaths(const unsigned int iMaxSteps, const unsigned int iMaxPaths, STPathSet& spsDst); - - bool bDefaultPath(const STPath& spPath); }; boost::unordered_set usAccountDestCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger, diff --git a/src/cpp/ripple/Peer.h b/src/cpp/ripple/Peer.h index dcea202765..180b2c8422 100644 --- a/src/cpp/ripple/Peer.h +++ b/src/cpp/ripple/Peer.h @@ -61,7 +61,6 @@ private: void handlePingTimer(const boost::system::error_code& ecResult); protected: - boost::asio::io_service::strand mIOStrand; std::vector mReadbuf; std::list mSendQ; diff --git a/src/cpp/ripple/ProofOfWork.h b/src/cpp/ripple/ProofOfWork.h index 20492f4329..994f2ac7aa 100644 --- a/src/cpp/ripple/ProofOfWork.h +++ b/src/cpp/ripple/ProofOfWork.h @@ -22,16 +22,6 @@ bool powResultInfo(POWResult powCode, std::string& strToken, std::string& strHum class ProofOfWork { -protected: - - std::string mToken; - uint256 mChallenge; - uint256 mTarget; - int mIterations; - - static const uint256 sMinTarget; - static const int sMaxIterations; - public: static const int sMaxDifficulty; @@ -56,6 +46,15 @@ public: uint64 getDifficulty() const { return getDifficulty(mTarget, mIterations); } static bool validateToken(const std::string& strToken); + +private: + std::string mToken; + uint256 mChallenge; + uint256 mTarget; + int mIterations; + + static const uint256 sMinTarget; + static const int sMaxIterations; }; class ProofOfWorkGenerator @@ -64,17 +63,6 @@ public: typedef boost::bimap< boost::bimaps::multiset_of, boost::bimaps::unordered_set_of > powMap_t; typedef powMap_t::value_type powMap_vt; -protected: - uint256 mSecret; - int mIterations; - uint256 mTarget; - time_t mLastDifficultyChange; - int mValidTime; - int mPowEntry; - - powMap_t mSolvedChallenges; - boost::mutex mLock; - public: ProofOfWorkGenerator(); @@ -91,6 +79,17 @@ public: void setSecret(const uint256& secret) { mSecret = secret; } static int getPowEntry(const uint256& target, int iterations); + +private: + uint256 mSecret; + int mIterations; + uint256 mTarget; + time_t mLastDifficultyChange; + int mValidTime; + int mPowEntry; + + powMap_t mSolvedChallenges; + boost::mutex mLock; }; #endif diff --git a/src/cpp/ripple/RPCHandler.h b/src/cpp/ripple/RPCHandler.h index 1a97efeccf..ceb5ea2009 100644 --- a/src/cpp/ripple/RPCHandler.h +++ b/src/cpp/ripple/RPCHandler.h @@ -133,19 +133,20 @@ class RPCInternalHandler public: typedef Json::Value (*handler_t)(const Json::Value&); -protected: +public: + RPCInternalHandler(const std::string& name, handler_t handler); + static Json::Value runHandler(const std::string& name, const Json::Value& params); + +private: static RPCInternalHandler* sHeadHandler; RPCInternalHandler* mNextHandler; std::string mName; handler_t mHandler; - -public: - RPCInternalHandler(const std::string& name, handler_t handler); - static Json::Value runHandler(const std::string& name, const Json::Value& params); }; -int iAdminGet(const Json::Value& jvRequest, const std::string& strRemoteIp); +// VFALCO: TODO, tidy up this loose function +int iAdminGet (const Json::Value& jvRequest, const std::string& strRemoteIp); #endif // vim:ts=4 diff --git a/src/cpp/ripple/RPCSub.h b/src/cpp/ripple/RPCSub.h index 91ab300ede..8eb67f923d 100644 --- a/src/cpp/ripple/RPCSub.h +++ b/src/cpp/ripple/RPCSub.h @@ -10,23 +10,6 @@ // Subscription object for JSON-RPC class RPCSub : public InfoSub { - std::string mUrl; - std::string mIp; - int mPort; - bool mSSL; - std::string mUsername; - std::string mPassword; - std::string mPath; - - int mSeq; // Next id to allocate. - - bool mSending; // Sending threead is active. - - std::deque > mDeque; - -protected: - void sendThread(); - public: typedef boost::shared_ptr pointer; typedef const pointer& ref; @@ -51,6 +34,24 @@ public: mPassword = strPassword; } + +protected: + void sendThread(); + +private: + std::string mUrl; + std::string mIp; + int mPort; + bool mSSL; + std::string mUsername; + std::string mPassword; + std::string mPath; + + int mSeq; // Next id to allocate. + + bool mSending; // Sending threead is active. + + std::deque > mDeque; }; #endif diff --git a/src/cpp/ripple/RippleCalc.h b/src/cpp/ripple/RippleCalc.h index 74b76770e8..2bdc641fe0 100644 --- a/src/cpp/ripple/RippleCalc.h +++ b/src/cpp/ripple/RippleCalc.h @@ -6,8 +6,16 @@ #include "LedgerEntrySet.h" -class PaymentNode { -protected: +// VFALCO: TODO, move this to a separate file +class PaymentNode +{ +public: + bool operator==(const PaymentNode& pnOther) const; + + Json::Value getJson() const; + +private: + // VFALCO: TODO, remove the need for friend declaration friend class RippleCalc; friend class PathState; @@ -54,10 +62,6 @@ protected: STAmount saTakerPays; STAmount saTakerGets; -public: - bool operator==(const PaymentNode& pnOther) const; - - Json::Value getJson() const; }; // account id, currency id, issuer id :: node @@ -70,10 +74,6 @@ extern std::size_t hash_value(const aciSource& asValue); // Holds a path state under incremental application. class PathState { -protected: - TER pushNode(const int iType, const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); - TER pushImply(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); - public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; @@ -146,14 +146,14 @@ public: } #endif static bool lessPriority(PathState& lhs, PathState& rhs); + +private: + TER pushNode(const int iType, const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); + TER pushImply(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); }; class RippleCalc { -protected: - LedgerEntrySet& lesActive; - bool mOpenLedger; - public: // First time working in reverse a funding source was mentioned. Source may only be used there. curIssuerNode mumSource; // Map of currency, issuer to node index. @@ -213,6 +213,10 @@ public: ); static void setCanonical(STPathSet& spsDst, const std::vector& vpsExpanded, bool bKeepDefault); + +protected: + LedgerEntrySet& lesActive; + bool mOpenLedger; }; #endif diff --git a/src/cpp/ripple/SHAMap.h b/src/cpp/ripple/SHAMap.h index 2e3ea10e5c..f936da75e6 100644 --- a/src/cpp/ripple/SHAMap.h +++ b/src/cpp/ripple/SHAMap.h @@ -21,21 +21,9 @@ class SHAMapSyncFilter; // A tree-like map of SHA256 hashes // The trees are designed for rapid synchronization and compression of differences - +// Identifies a node in a SHA256 hash map class SHAMapNode -{ // Identifies a node in a SHA256 hash map -private: - static uint256 smMasks[65]; // AND with hash to get node id - - uint256 mNodeID; - int mDepth; - mutable size_t mHash; - - void setMHash() const; - -protected: - SHAMapNode(int depth, const uint256& id, bool) : mNodeID(id), mDepth(depth), mHash(0) { ; } - +{ public: static const int rootDepth = 0; @@ -81,6 +69,18 @@ public: std::string getRawString() const; static int getRawIDLength(void) { return 33; } SHAMapNode(const void *ptr, int len); + +protected: + SHAMapNode(int depth, const uint256& id, bool) : mNodeID(id), mDepth(depth), mHash(0) { ; } + +private: + static uint256 smMasks[65]; // AND with hash to get node id + + uint256 mNodeID; + int mDepth; + mutable size_t mHash; + + void setMHash() const; }; extern std::size_t hash_value(const SHAMapNode& mn); @@ -259,12 +259,6 @@ public: class SHAMapMissingNode : public std::runtime_error { -protected: - SHAMapType mType; - SHAMapNode mNodeID; - uint256 mNodeHash; - uint256 mTargetIndex; - public: SHAMapMissingNode(SHAMapType t, const SHAMapNode& nodeID, const uint256& nodeHash) : std::runtime_error("SHAMapMissingNode"), mType(t), mNodeID(nodeID), mNodeHash(nodeHash) @@ -285,17 +279,19 @@ public: const uint256& getNodeHash() const { return mNodeHash; } const uint256& getTargetIndex() const { return mTargetIndex; } bool hasTargetIndex() const { return !mTargetIndex.isZero(); } + +private: + SHAMapType mType; + SHAMapNode mNodeID; + uint256 mNodeHash; + uint256 mTargetIndex; }; extern std::ostream& operator<<(std::ostream&, const SHAMapMissingNode&); +// results of adding nodes class SMAddNode -{ // results of adding nodes -protected: - bool mInvalid, mUseful; - - SMAddNode(bool i, bool u) : mInvalid(i), mUseful(u) { ; } - +{ public: SMAddNode() : mInvalid(false), mUseful(false) { ; } @@ -323,13 +319,18 @@ public: static SMAddNode okay() { return SMAddNode(false, false); } static SMAddNode useful() { return SMAddNode(false, true); } static SMAddNode invalid() { return SMAddNode(true, false); } + +private: + bool mInvalid, mUseful; + + SMAddNode(bool i, bool u) : mInvalid(i), mUseful(u) { ; } }; +// VFALCO: TODO, tidy up this loose function extern bool SMANCombine(SMAddNode& existing, const SMAddNode& additional); class SHAMap : public IS_INSTANCE(SHAMap) { - public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; @@ -338,48 +339,7 @@ public: typedef std::map SHAMapDiff; typedef boost::unordered_map SHADirtyMap; -protected: - uint32 mSeq; - uint32 mLedgerSeq; // sequence number of ledger this is part of - mutable boost::recursive_mutex mLock; - boost::unordered_map mTNByID; - - boost::shared_ptr mDirtyNodes; - - SHAMapTreeNode::pointer root; - - SHAMapState mState; - - SHAMapType mType; - - static KeyCache fullBelowCache; - - void dirtyUp(std::stack& stack, const uint256& target, uint256 prevHash); - std::stack getStack(const uint256& id, bool include_nonmatching_leaf, bool partialOk); - SHAMapTreeNode::pointer walkTo(const uint256& id, bool modify); - SHAMapTreeNode* walkToPointer(const uint256& id); - SHAMapTreeNode::pointer checkCacheNode(const SHAMapNode&); - void returnNode(SHAMapTreeNode::pointer&, bool modify); - void trackNewNode(SHAMapTreeNode::pointer&); - - SHAMapTreeNode::pointer getNode(const SHAMapNode& id); - SHAMapTreeNode::pointer getNode(const SHAMapNode& id, const uint256& hash, bool modify); - SHAMapTreeNode* getNodePointer(const SHAMapNode& id, const uint256& hash); - SHAMapTreeNode* getNodePointer(const SHAMapNode& id, const uint256& hash, SHAMapSyncFilter* filter); - SHAMapTreeNode* firstBelow(SHAMapTreeNode*); - SHAMapTreeNode* lastBelow(SHAMapTreeNode*); - - SHAMapItem::pointer onlyBelow(SHAMapTreeNode*); - void eraseChildren(SHAMapTreeNode::pointer); - void dropBelow(SHAMapTreeNode*); - bool hasInnerNode(const SHAMapNode& nodeID, const uint256& hash); - bool hasLeafNode(const uint256& tag, const uint256& hash); - - bool walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool isFirstMap, - SHAMapDiff& differences, int& maxCount); - public: - // build new map SHAMap(SHAMapType t, uint32 seq = 1); SHAMap(SHAMapType t, const uint256& hash); @@ -481,6 +441,46 @@ public: std::list getFetchPack(SHAMap* have, bool includeLeaves, int max); static void sweep() { fullBelowCache.sweep(); } + +private: + uint32 mSeq; + uint32 mLedgerSeq; // sequence number of ledger this is part of + mutable boost::recursive_mutex mLock; + boost::unordered_map mTNByID; + + boost::shared_ptr mDirtyNodes; + + SHAMapTreeNode::pointer root; + + SHAMapState mState; + + SHAMapType mType; + + static KeyCache fullBelowCache; + + void dirtyUp(std::stack& stack, const uint256& target, uint256 prevHash); + std::stack getStack(const uint256& id, bool include_nonmatching_leaf, bool partialOk); + SHAMapTreeNode::pointer walkTo(const uint256& id, bool modify); + SHAMapTreeNode* walkToPointer(const uint256& id); + SHAMapTreeNode::pointer checkCacheNode(const SHAMapNode&); + void returnNode(SHAMapTreeNode::pointer&, bool modify); + void trackNewNode(SHAMapTreeNode::pointer&); + + SHAMapTreeNode::pointer getNode(const SHAMapNode& id); + SHAMapTreeNode::pointer getNode(const SHAMapNode& id, const uint256& hash, bool modify); + SHAMapTreeNode* getNodePointer(const SHAMapNode& id, const uint256& hash); + SHAMapTreeNode* getNodePointer(const SHAMapNode& id, const uint256& hash, SHAMapSyncFilter* filter); + SHAMapTreeNode* firstBelow(SHAMapTreeNode*); + SHAMapTreeNode* lastBelow(SHAMapTreeNode*); + + SHAMapItem::pointer onlyBelow(SHAMapTreeNode*); + void eraseChildren(SHAMapTreeNode::pointer); + void dropBelow(SHAMapTreeNode*); + bool hasInnerNode(const SHAMapNode& nodeID, const uint256& hash); + bool hasLeafNode(const uint256& tag, const uint256& hash); + + bool walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool isFirstMap, + SHAMapDiff& differences, int& maxCount); }; #endif diff --git a/src/cpp/ripple/SHAMapSync.h b/src/cpp/ripple/SHAMapSync.h index 60e55a139a..5f8faa0066 100644 --- a/src/cpp/ripple/SHAMapSync.h +++ b/src/cpp/ripple/SHAMapSync.h @@ -20,11 +20,9 @@ public: }; // This class is only needed on add functions +// sync filter for account state nodes during ledger sync class AccountStateSF : public SHAMapSyncFilter -{ // sync filter for account state nodes during ledger sync -protected: - uint32 mLedgerSeq; - +{ public: AccountStateSF(uint32 ledgerSeq) : mLedgerSeq(ledgerSeq) { ; } @@ -38,14 +36,15 @@ public: { return theApp->getOPs().getFetchPack(nodeHash, nodeData); } + +private: + uint32 mLedgerSeq; }; // This class is only needed on add functions +// sync filter for transactions tree during ledger sync class TransactionStateSF : public SHAMapSyncFilter -{ // sync filter for transactions tree during ledger sync -protected: - uint32 mLedgerSeq; - +{ public: TransactionStateSF(uint32 ledgerSeq) : mLedgerSeq(ledgerSeq) { ; } @@ -61,6 +60,9 @@ public: { return theApp->getOPs().getFetchPack(nodeHash, nodeData); } + +private: + uint32 mLedgerSeq; }; #endif diff --git a/src/cpp/ripple/SNTPClient.h b/src/cpp/ripple/SNTPClient.h index 00d76eb667..7b1b31ac88 100644 --- a/src/cpp/ripple/SNTPClient.h +++ b/src/cpp/ripple/SNTPClient.h @@ -21,7 +21,16 @@ public: class SNTPClient { -protected: +public: + SNTPClient(boost::asio::io_service& service); + void init(const std::vector& servers); + void addServer(const std::string& mServer); + + void queryAll(); + bool doQuery(); + bool getOffset(int& offset); + +private: std::map mQueries; boost::mutex mLock; @@ -44,15 +53,6 @@ protected: void timerEntry(const boost::system::error_code&); void sendComplete(const boost::system::error_code& error, std::size_t bytesTransferred); void processReply(); - -public: - SNTPClient(boost::asio::io_service& service); - void init(const std::vector& servers); - void addServer(const std::string& mServer); - - void queryAll(); - bool doQuery(); - bool getOffset(int& offset); }; #endif diff --git a/src/cpp/ripple/SerializedLedger.h b/src/cpp/ripple/SerializedLedger.h index b8f43ff075..de88bfa2bf 100644 --- a/src/cpp/ripple/SerializedLedger.h +++ b/src/cpp/ripple/SerializedLedger.h @@ -13,14 +13,6 @@ public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; -protected: - uint256 mIndex; - LedgerEntryType mType; - const LedgerEntryFormat* mFormat; - bool mMutable; - - SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); } - public: SerializedLedgerEntry(const Serializer& s, const uint256& index); SerializedLedgerEntry(SerializerIterator& sit, const uint256& index); @@ -53,6 +45,14 @@ public: uint32 getThreadedLedger(); bool thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID); std::vector getOwners(); // nodes notified if this node is deleted + +private: + uint256 mIndex; + LedgerEntryType mType; + const LedgerEntryFormat* mFormat; + bool mMutable; + + SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); } }; typedef SerializedLedgerEntry SLE; diff --git a/src/cpp/ripple/SerializedObject.h b/src/cpp/ripple/SerializedObject.h index d888d1e6ec..5ca6aec2b4 100644 --- a/src/cpp/ripple/SerializedObject.h +++ b/src/cpp/ripple/SerializedObject.h @@ -23,27 +23,19 @@ public: class SOTemplate { -protected: - std::vector mTypes; - std::vector mIndex; // field num -> index - public: SOTemplate() { ; } const std::vector& peek() const { return mTypes; } void push_back(const SOElement& r); int getIndex(SField::ref) const; + +private: + std::vector mTypes; + std::vector mIndex; // field num -> index }; class STObject : public SerializedType, private IS_INSTANCE(SerializedObject) { -protected: - boost::ptr_vector mData; - const SOTemplate* mType; - - STObject* duplicate() const { return new STObject(*this); } - STObject(SField::ref name, boost::ptr_vector& data) : SerializedType(name), mType(NULL) - { mData.swap(data); } - public: STObject() : mType(NULL) { ; } @@ -176,6 +168,14 @@ public: bool operator==(const STObject& o) const; bool operator!=(const STObject& o) const { return ! (*this == o); } + +private: + boost::ptr_vector mData; + const SOTemplate* mType; + + STObject* duplicate() const { return new STObject(*this); } + STObject(SField::ref name, boost::ptr_vector& data) : SerializedType(name), mType(NULL) + { mData.swap(data); } }; // allow ptr_* collections of STObject's @@ -202,15 +202,7 @@ public: typedef boost::ptr_vector::const_reverse_iterator const_reverse_iterator; typedef boost::ptr_vector::size_type size_type; -protected: - - vector value; - - STArray* duplicate() const { return new STArray(*this); } - static STArray* construct(SerializerIterator&, SField::ref); - public: - STArray() { ; } STArray(int n) { value.reserve(n); } STArray(SField::ref f) : SerializedType(f) { ; } @@ -260,6 +252,12 @@ public: virtual SerializedTypeID getSType() const { return STI_ARRAY; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.empty(); } + +private: + vector value; + + STArray* duplicate() const { return new STArray(*this); } + static STArray* construct(SerializerIterator&, SField::ref); }; inline STArray::iterator range_begin(STArray& x) { return x.begin(); } diff --git a/src/cpp/ripple/SerializedTransaction.h b/src/cpp/ripple/SerializedTransaction.h index eb725bdbf6..b49c783835 100644 --- a/src/cpp/ripple/SerializedTransaction.h +++ b/src/cpp/ripple/SerializedTransaction.h @@ -23,14 +23,6 @@ public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; -protected: - TransactionType mType; - const TransactionFormat* mFormat; - - SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); } - - mutable bool mSigGood, mSigBad; - public: SerializedTransaction(SerializerIterator& sit); SerializedTransaction(TransactionType type); @@ -89,6 +81,13 @@ public: std::string getMetaSQL(uint32 inLedger, const std::string& escapedMetaData) const; std::string getMetaSQL(Serializer rawTxn, uint32 inLedger, char status, const std::string& escapedMetaData) const; +private: + TransactionType mType; + const TransactionFormat* mFormat; + + SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); } + + mutable bool mSigGood, mSigBad; }; #endif diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index 6a3cb2fd3d..d66be3ab1b 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -38,11 +38,6 @@ static inline const uint160& get_u160_one() { return u160_one; } class SerializedType { -protected: - SField::ptr fName; - - virtual SerializedType* duplicate() const { return new SerializedType(*fName); } - public: SerializedType() : fName(&sfGeneric) { ; } @@ -80,6 +75,13 @@ public: { return (getSType() != t.getSType()) || !isEquivalent(t); } virtual bool isDefault() const { return true; } + +protected: + // VFALCO: TODO, make accessors for this + SField::ptr fName; + +private: + virtual SerializedType* duplicate() const { return new SerializedType(*fName); } }; inline SerializedType* new_clone(const SerializedType& s) { return s.clone().release(); } @@ -88,12 +90,6 @@ inline std::ostream& operator<<(std::ostream& out, const SerializedType& t) { re class STUInt8 : public SerializedType { -protected: - unsigned char value; - - STUInt8* duplicate() const { return new STUInt8(*this); } - static STUInt8* construct(SerializerIterator&, SField::ref f); - public: STUInt8(unsigned char v = 0) : value(v) { ; } @@ -112,16 +108,16 @@ public: operator unsigned char() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value == 0; } + +private: + unsigned char value; + + STUInt8* duplicate() const { return new STUInt8(*this); } + static STUInt8* construct(SerializerIterator&, SField::ref f); }; class STUInt16 : public SerializedType { -protected: - uint16 value; - - STUInt16* duplicate() const { return new STUInt16(*this); } - static STUInt16* construct(SerializerIterator&, SField::ref name); - public: STUInt16(uint16 v = 0) : value(v) { ; } @@ -140,16 +136,16 @@ public: operator uint16() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value == 0; } + +private: + uint16 value; + + STUInt16* duplicate() const { return new STUInt16(*this); } + static STUInt16* construct(SerializerIterator&, SField::ref name); }; class STUInt32 : public SerializedType { -protected: - uint32 value; - - STUInt32* duplicate() const { return new STUInt32(*this); } - static STUInt32* construct(SerializerIterator&, SField::ref name); - public: STUInt32(uint32 v = 0) : value(v) { ; } @@ -168,16 +164,16 @@ public: operator uint32() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value == 0; } + +private: + uint32 value; + + STUInt32* duplicate() const { return new STUInt32(*this); } + static STUInt32* construct(SerializerIterator&, SField::ref name); }; class STUInt64 : public SerializedType { -protected: - uint64 value; - - STUInt64* duplicate() const { return new STUInt64(*this); } - static STUInt64* construct(SerializerIterator&, SField::ref name); - public: STUInt64(uint64 v = 0) : value(v) { ; } @@ -196,66 +192,26 @@ public: operator uint64() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value == 0; } + +private: + uint64 value; + + STUInt64* duplicate() const { return new STUInt64(*this); } + static STUInt64* construct(SerializerIterator&, SField::ref name); }; +// Internal form: +// 1: If amount is zero, then value is zero and offset is -100 +// 2: Otherwise: +// legal offset range is -96 to +80 inclusive +// value range is 10^15 to (10^16 - 1) inclusive +// amount = value * [10 ^ offset] + +// Wire form: +// High 8 bits are (offset+142), legal range is, 80 to 22 inclusive +// Low 56 bits are value, legal range is 10^15 to (10^16 - 1) inclusive class STAmount : public SerializedType { - // Internal form: - // 1: If amount is zero, then value is zero and offset is -100 - // 2: Otherwise: - // legal offset range is -96 to +80 inclusive - // value range is 10^15 to (10^16 - 1) inclusive - // amount = value * [10 ^ offset] - - // Wire form: - // High 8 bits are (offset+142), legal range is, 80 to 22 inclusive - // Low 56 bits are value, legal range is 10^15 to (10^16 - 1) inclusive - -protected: - uint160 mCurrency; // Compared by ==. Always update mIsNative. - uint160 mIssuer; // Not compared by ==. 0 for XRP. - - uint64 mValue; - int mOffset; - bool mIsNative; // Always !mCurrency. Native is XRP. - bool mIsNegative; - - void canonicalize(); - STAmount* duplicate() const { return new STAmount(*this); } - static STAmount* construct(SerializerIterator&, SField::ref name); - - STAmount(SField::ref name, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg) - : SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off), - mIsNative(isNat), mIsNegative(isNeg) { ; } - - void set(int64 v) - { - if (v < 0) - { - mIsNegative = true; - mValue = static_cast(-v); - } - else - { - mIsNegative = false; - mValue = static_cast(v); - } - } - - void set(int v) - { - if (v < 0) - { - mIsNegative = true; - mValue = static_cast(-v); - } - else - { - mIsNegative = false; - mValue = static_cast(v); - } - } - public: static const int cMinOffset = -96, cMaxOffset = 80; static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull; @@ -469,6 +425,51 @@ public: STAmount getRound() const; void roundSelf(); + +private: + uint160 mCurrency; // Compared by ==. Always update mIsNative. + uint160 mIssuer; // Not compared by ==. 0 for XRP. + + uint64 mValue; + int mOffset; + bool mIsNative; // Always !mCurrency. Native is XRP. + bool mIsNegative; + + void canonicalize(); + STAmount* duplicate() const { return new STAmount(*this); } + static STAmount* construct(SerializerIterator&, SField::ref name); + + STAmount(SField::ref name, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg) + : SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off), + mIsNative(isNat), mIsNegative(isNeg) { ; } + + void set(int64 v) + { + if (v < 0) + { + mIsNegative = true; + mValue = static_cast(-v); + } + else + { + mIsNegative = false; + mValue = static_cast(v); + } + } + + void set(int v) + { + if (v < 0) + { + mIsNegative = true; + mValue = static_cast(-v); + } + else + { + mIsNegative = false; + mValue = static_cast(v); + } + } }; extern const STAmount saZero; @@ -476,14 +477,7 @@ extern const STAmount saOne; class STHash128 : public SerializedType { -protected: - uint128 value; - - STHash128* duplicate() const { return new STHash128(*this); } - static STHash128* construct(SerializerIterator&, SField::ref name); - public: - STHash128(const uint128& v) : value(v) { ; } STHash128(SField::ref n, const uint128& v) : SerializedType(n), value(v) { ; } STHash128(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); } @@ -503,18 +497,17 @@ public: operator uint128() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.isZero(); } + +private: + uint128 value; + + STHash128* duplicate() const { return new STHash128(*this); } + static STHash128* construct(SerializerIterator&, SField::ref name); }; class STHash160 : public SerializedType { -protected: - uint160 value; - - STHash160* duplicate() const { return new STHash160(*this); } - static STHash160* construct(SerializerIterator&, SField::ref name); - public: - STHash160(const uint160& v) : value(v) { ; } STHash160(SField::ref n, const uint160& v) : SerializedType(n), value(v) { ; } STHash160(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); } @@ -534,18 +527,17 @@ public: operator uint160() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.isZero(); } + +private: + uint160 value; + + STHash160* duplicate() const { return new STHash160(*this); } + static STHash160* construct(SerializerIterator&, SField::ref name); }; class STHash256 : public SerializedType { -protected: - uint256 value; - - STHash256* duplicate() const { return new STHash256(*this); } - static STHash256* construct(SerializerIterator&, SField::ref); - public: - STHash256(const uint256& v) : value(v) { ; } STHash256(SField::ref n, const uint256& v) : SerializedType(n), value(v) { ; } STHash256(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); } @@ -565,18 +557,18 @@ public: operator uint256() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.isZero(); } + +private: + uint256 value; + + STHash256* duplicate() const { return new STHash256(*this); } + static STHash256* construct(SerializerIterator&, SField::ref); }; +// variable length byte string class STVariableLength : public SerializedType -{ // variable length byte string protected: -protected: - std::vector value; - - virtual STVariableLength* duplicate() const { return new STVariableLength(*this); } - static STVariableLength* construct(SerializerIterator&, SField::ref); - +{ public: - STVariableLength(const std::vector& v) : value(v) { ; } STVariableLength(SField::ref n, const std::vector& v) : SerializedType(n), value(v) { ; } STVariableLength(SField::ref n) : SerializedType(n) { ; } @@ -597,16 +589,17 @@ public: operator std::vector() const { return value; } virtual bool isEquivalent(const SerializedType& t) const; virtual bool isDefault() const { return value.empty(); } + +private: + std::vector value; + + virtual STVariableLength* duplicate() const { return new STVariableLength(*this); } + static STVariableLength* construct(SerializerIterator&, SField::ref); }; class STAccount : public STVariableLength { -protected: - virtual STAccount* duplicate() const { return new STAccount(*this); } - static STAccount* construct(SerializerIterator&, SField::ref); - public: - STAccount(const std::vector& v) : STVariableLength(v) { ; } STAccount(SField::ref n, const std::vector& v) : STVariableLength(n, v) { ; } STAccount(SField::ref n, const uint160& v); @@ -624,13 +617,20 @@ public: void setValueH160(const uint160& v); bool getValueH160(uint160&) const; bool isValueH160() const; + +private: + virtual STAccount* duplicate() const { return new STAccount(*this); } + static STAccount* construct(SerializerIterator&, SField::ref); }; class STPathElement { - friend class STPathSet; - friend class STPath; - friend class Pathfinder; +private: + // VFALCO: Remove these friend declarations + friend class STPathSet; + friend class STPath; + friend class Pathfinder; + public: enum { typeEnd = 0x00, @@ -645,12 +645,6 @@ public: ), // Bits that may be non-zero. }; -protected: - unsigned int mType; - uint160 mAccountID; - uint160 mCurrencyID; - uint160 mIssuerID; - public: STPathElement(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID, bool forceCurrency = false) @@ -682,15 +676,16 @@ public: return mType == t.mType && mAccountID == t.mAccountID && mCurrencyID == t.mCurrencyID && mIssuerID == t.mIssuerID; } + +private: + unsigned int mType; + uint160 mAccountID; + uint160 mCurrencyID; + uint160 mIssuerID; }; class STPath { - friend class STPathSet; - friend class Pathfinder; -protected: - std::vector mPath; - public: STPath() { ; } STPath(const std::vector& p) : mPath(p) { ; } @@ -717,6 +712,12 @@ public: bool operator==(const STPath& t) const { return mPath == t.mPath; } void setCanonical(const STPath& spExpanded); + +private: + friend class STPathSet; + friend class Pathfinder; + + std::vector mPath; }; inline std::vector::iterator range_begin(STPath & x) @@ -754,21 +755,22 @@ namespace boost }; } +// A set of zero or more payment paths class STPathSet : public SerializedType -{ // A set of zero or more payment paths -protected: - std::vector value; - - STPathSet* duplicate() const { return new STPathSet(*this); } - static STPathSet* construct(SerializerIterator&, SField::ref); - +{ public: - STPathSet() { ; } - STPathSet(SField::ref n) : SerializedType(n) { ; } - STPathSet(const std::vector& v) : value(v) { ; } - STPathSet(SField::ref n, const std::vector& v) : SerializedType(n), value(v) { ; } - static UPTR_T deserialize(SerializerIterator& sit, SField::ref name) - { return UPTR_T(construct(sit, name)); } + STPathSet () { ; } + + explicit STPathSet(SField::ref n) : SerializedType(n) { ; } + + explicit STPathSet(const std::vector& v) : value(v) { ; } + + STPathSet(SField::ref n, const std::vector& v) : SerializedType(n), value(v) { ; } + + static UPTR_T deserialize(SerializerIterator& sit, SField::ref name) + { + return UPTR_T(construct(sit, name)); + } // std::string getText() const; void add(Serializer& s) const; @@ -791,6 +793,12 @@ public: std::vector::iterator end() { return value.end(); } std::vector::const_iterator begin() const { return value.begin(); } std::vector::const_iterator end() const { return value.end(); } + +private: + std::vector value; + + STPathSet* duplicate() const { return new STPathSet(*this); } + static STPathSet* construct(SerializerIterator&, SField::ref); }; inline std::vector::iterator range_begin(STPathSet & x) @@ -830,12 +838,6 @@ namespace boost class STVector256 : public SerializedType { -protected: - std::vector mValue; - - STVector256* duplicate() const { return new STVector256(*this); } - static STVector256* construct(SerializerIterator&, SField::ref); - public: STVector256() { ; } STVector256(SField::ref n) : SerializedType(n) { ; } @@ -867,6 +869,12 @@ public: void sort() { std::sort(mValue.begin(), mValue.end()); } Json::Value getJson(int) const; + +private: + std::vector mValue; + + STVector256* duplicate() const { return new STVector256(*this); } + static STVector256* construct(SerializerIterator&, SField::ref); }; #endif diff --git a/src/cpp/ripple/SerializedValidation.h b/src/cpp/ripple/SerializedValidation.h index a14a10d04d..f4cf84af79 100644 --- a/src/cpp/ripple/SerializedValidation.h +++ b/src/cpp/ripple/SerializedValidation.h @@ -7,13 +7,6 @@ DEFINE_INSTANCE(SerializedValidation); class SerializedValidation : public STObject, private IS_INSTANCE(SerializedValidation) { -protected: - uint256 mPreviousHash; - uint160 mNodeID; - bool mTrusted; - - void setNode(); - public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; @@ -47,6 +40,13 @@ public: const uint256& getPreviousHash() { return mPreviousHash; } bool isPreviousHash(const uint256& h) { return mPreviousHash == h; } void setPreviousHash(const uint256& h) { mPreviousHash = h; } + +private: + uint256 mPreviousHash; + uint160 mNodeID; + bool mTrusted; + + void setNode(); }; #endif diff --git a/src/cpp/ripple/TransactionMaster.h b/src/cpp/ripple/TransactionMaster.h index 2b110d50d2..38b84e930e 100644 --- a/src/cpp/ripple/TransactionMaster.h +++ b/src/cpp/ripple/TransactionMaster.h @@ -7,11 +7,7 @@ class TransactionMaster { -protected: - TaggedCache mCache; - public: - TransactionMaster(); Transaction::pointer fetch(const uint256&, bool checkDisk); @@ -22,6 +18,9 @@ public: bool inLedger(const uint256& hash, uint32 ledger); bool canonicalize(Transaction::pointer& txn, bool maybeNew); void sweep(void) { mCache.sweep(); } + +private: + TaggedCache mCache; }; #endif diff --git a/src/cpp/ripple/TransactionMeta.h b/src/cpp/ripple/TransactionMeta.h index cf734e6f29..260e9ff9d1 100644 --- a/src/cpp/ripple/TransactionMeta.h +++ b/src/cpp/ripple/TransactionMeta.h @@ -17,14 +17,6 @@ public: typedef boost::shared_ptr pointer; typedef const pointer& ref; -protected: - uint256 mTransactionID; - uint32 mLedger; - uint32 mIndex; - int mResult; - - STArray mNodes; - public: TransactionMetaSet() : mLedger(0), mIndex(static_cast(-1)), mResult(255) { ; } TransactionMetaSet(const uint256& txID, uint32 ledger, uint32 index) : @@ -56,6 +48,14 @@ public: STArray& getNodes(){ return(mNodes); } static bool thread(STObject& node, const uint256& prevTxID, uint32 prevLgrID); + +private: + uint256 mTransactionID; + uint32 mLedger; + uint32 mIndex; + int mResult; + + STArray mNodes; }; #endif diff --git a/src/cpp/ripple/TransactionQueue.h b/src/cpp/ripple/TransactionQueue.h index 843a78aa2c..041b6ea37e 100644 --- a/src/cpp/ripple/TransactionQueue.h +++ b/src/cpp/ripple/TransactionQueue.h @@ -16,20 +16,11 @@ class TXQeueue; class TXQEntry { - friend class TXQueue; - public: typedef boost::shared_ptr pointer; typedef const boost::shared_ptr& ref; typedef FUNCTION_TYPE stCallback; // must complete immediately -protected: - Transaction::pointer mTxn; - bool mSigChecked; - std::list mCallbacks; - - void addCallbacks(const TXQEntry& otherEntry); - public: TXQEntry(Transaction::ref tx, bool sigChecked) : mTxn(tx), mSigChecked(sigChecked) { ; } TXQEntry() : mSigChecked(false) { ; } @@ -39,22 +30,20 @@ public: const uint256& getID() const { return mTxn->getID(); } void doCallbacks(TER); + +private: + friend class TXQueue; + + Transaction::pointer mTxn; + bool mSigChecked; + std::list mCallbacks; + + void addCallbacks(const TXQEntry& otherEntry); }; class TXQueue { -protected: - typedef boost::bimaps::unordered_set_of leftType; - typedef boost::bimaps::list_of rightType; - typedef boost::bimap mapType; - typedef mapType::value_type valueType; - - mapType mTxMap; - bool mRunning; - boost::mutex mLock; - public: - TXQueue() : mRunning(false) { ; } // Return: true = must dispatch signature checker thread @@ -69,6 +58,16 @@ public: // Transaction execution interface void getJob(TXQEntry::pointer&); bool stopProcessing(TXQEntry::ref finishedJob); + +private: + typedef boost::bimaps::unordered_set_of leftType; + typedef boost::bimaps::list_of rightType; + typedef boost::bimap mapType; + typedef mapType::value_type valueType; + + mapType mTxMap; + bool mRunning; + boost::mutex mLock; }; #endif diff --git a/src/cpp/ripple/Transactor.h b/src/cpp/ripple/Transactor.h index 4c50a47be2..09fcd892f8 100644 --- a/src/cpp/ripple/Transactor.h +++ b/src/cpp/ripple/Transactor.h @@ -9,6 +9,13 @@ class Transactor { +public: + typedef boost::shared_ptr pointer; + + static UPTR_T makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine); + + TER apply(); + protected: const SerializedTransaction& mTxn; TransactionEngine* mEngine; @@ -37,13 +44,6 @@ protected: Transactor(const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine); virtual bool mustHaveValidAccount() { return true; } - -public: - typedef boost::shared_ptr pointer; - - static UPTR_T makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine); - - TER apply(); }; #endif diff --git a/src/cpp/ripple/WSConnection.h b/src/cpp/ripple/WSConnection.h index ec414ee2ac..1ec35fad78 100644 --- a/src/cpp/ripple/WSConnection.h +++ b/src/cpp/ripple/WSConnection.h @@ -37,23 +37,6 @@ public: typedef typename boost::weak_ptr weak_connection_ptr; typedef typename endpoint_type::handler::message_ptr message_ptr; -protected: - typedef void (WSConnection::*doFuncPtr)(Json::Value& jvResult, Json::Value &jvRequest); - - WSServerHandler* mHandler; - weak_connection_ptr mConnection; - NetworkOPs& mNetwork; - std::string mRemoteIP; - LoadSource mLoadSource; - - boost::asio::deadline_timer mPingTimer; - bool mPinged; - - boost::recursive_mutex mRcvQueueLock; - std::queue mRcvQueue; - bool mRcvQueueRunning; - bool mDead; - public: // WSConnection() // : mHandler((WSServerHandler*)(NULL)), @@ -254,6 +237,22 @@ public: return m; } +private: + typedef void (WSConnection::*doFuncPtr)(Json::Value& jvResult, Json::Value &jvRequest); + + WSServerHandler* mHandler; + weak_connection_ptr mConnection; + NetworkOPs& mNetwork; + std::string mRemoteIP; + LoadSource mLoadSource; + + boost::asio::deadline_timer mPingTimer; + bool mPinged; + + boost::recursive_mutex mRcvQueueLock; + std::queue mRcvQueue; + bool mRcvQueueRunning; + bool mDead; }; // vim:ts=4 diff --git a/src/cpp/ripple/Wallet.h b/src/cpp/ripple/Wallet.h index c270cab4d3..853fa92ff6 100644 --- a/src/cpp/ripple/Wallet.h +++ b/src/cpp/ripple/Wallet.h @@ -23,16 +23,6 @@ private: Wallet(const Wallet&); // no implementation Wallet& operator=(const Wallet&); // no implementation -protected: - boost::recursive_mutex mLock; - - RippleAddress mNodePublicKey; - RippleAddress mNodePrivateKey; - DH* mDh512; - DH* mDh1024; - - uint32 mLedger; // ledger we last synched to - public: Wallet(); @@ -49,6 +39,16 @@ public: 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 diff --git a/src/cpp/ripple/ripple_IHashRouter.h b/src/cpp/ripple/ripple_IHashRouter.h index 0fa9293f1a..d84aedc3ff 100644 --- a/src/cpp/ripple/ripple_IHashRouter.h +++ b/src/cpp/ripple/ripple_IHashRouter.h @@ -14,10 +14,6 @@ DEFINE_INSTANCE (HashRouterEntry); // VFALCO: TODO move this class into the scope of class HashRouter class HashRouterEntry : private IS_INSTANCE (HashRouterEntry) { -protected: - int mFlags; - std::set mPeers; - public: HashRouterEntry () : mFlags(0) { ; } @@ -30,6 +26,10 @@ public: void setFlag(int f) { mFlags |= f; } void clearFlag(int f) { mFlags &= ~f; } void swapSet(std::set& s) { mPeers.swap(s); } + +protected: + int mFlags; + std::set mPeers; }; class IHashRouter