Downgrade access specification from protected to private in most places

Conflicts:
	src/cpp/ripple/FeatureTable.h
	src/cpp/ripple/HashedObject.h
	src/cpp/ripple/NetworkOPs.h
This commit is contained in:
Vinnie Falco
2013-06-02 19:44:50 -07:00
parent 594c47f16b
commit ee49051e1c
44 changed files with 866 additions and 840 deletions

View File

@@ -20,16 +20,6 @@
*/
class ALTransaction
{
protected:
SerializedTransaction::pointer mTxn;
TransactionMetaSet::pointer mMeta;
TER mResult;
std::vector<RippleAddress> mAffected;
std::vector<unsigned char> mRawMeta;
Json::Value mJson;
void buildJson();
public:
typedef boost::shared_ptr<ALTransaction> 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<RippleAddress> mAffected;
std::vector<unsigned char> 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<uint256, AcceptedLedger, UptimeTimerAdapter> 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<uint256, AcceptedLedger, UptimeTimerAdapter> ALCache;
AcceptedLedger(Ledger::ref ledger);
};
#endif

View File

@@ -9,8 +9,6 @@
//
class AccountItem
{
protected:
SerializedLedgerEntry::pointer mLedgerEntry;
public:
typedef boost::shared_ptr<AccountItem> pointer;
typedef const pointer& ref;
@@ -27,15 +25,14 @@ public:
SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; }
std::vector<unsigned char> 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<AccountItem::pointer> mItems;
void fillItems(const uint160& accountID, Ledger::ref ledger);
public:
typedef boost::shared_ptr<AccountItems> pointer;
@@ -43,6 +40,12 @@ public:
std::vector<AccountItem::pointer>& getItems() { return(mItems); }
Json::Value getJson(int);
private:
AccountItem::pointer mOfType;
std::vector<AccountItem::pointer> mItems;
void fillItems(const uint160& accountID, Ledger::ref ledger);
};
#endif

View File

@@ -33,12 +33,6 @@ public:
typedef boost::system::error_code error_code;
typedef boost::function<void(error_code)> callback;
protected:
socket_ptr mSocket;
bool mSecure;
std::vector<char> 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<char> mBuffer;
};
#endif

View File

@@ -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<std::string>& vCmd);

View File

@@ -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<CanonicalTXKey, SerializedTransaction::pointer>::iterator iterator;
typedef std::map<CanonicalTXKey, SerializedTransaction::pointer>::const_iterator const_iterator;
protected:
uint256 mSetHash;
std::map<CanonicalTXKey, SerializedTransaction::pointer> 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<CanonicalTXKey, SerializedTransaction::pointer> mMap;
};
#endif

View File

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

View File

@@ -389,11 +389,6 @@ Json::Value FeatureTable::getJson(const uint256& feature)
template<typename INT> class VotableInteger
{
protected:
INT mCurrent; // The current setting
INT mTarget; // The setting we want
std::map<INT, int> 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<INT, int> mVoteMap;
};
// vim:ts=4

View File

@@ -45,7 +45,6 @@ public:
void setFriendlyName(const std::string& n) { mFriendlyName = n; }
};
class FeatureTable
{
protected:

View File

@@ -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<std::string, std::string> 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<std::string, std::string> mHeaders;
int iDataSize;
bool bShouldClose;
};
#endif

View File

@@ -58,21 +58,7 @@ public:
class HashedObjectStore
{
protected:
TaggedCache<uint256, HashedObject, UptimeTimerAdapter> mCache;
KeyCache <uint256, UptimeTimerAdapter> mNegativeCache;
boost::mutex mWriteMutex;
boost::condition_variable mWriteCondition;
int mWriteGeneration;
int mWriteLoad;
std::vector< boost::shared_ptr<HashedObject> > 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<uint256, HashedObject, UptimeTimerAdapter> mCache;
KeyCache <uint256, UptimeTimerAdapter> mNegativeCache;
boost::mutex mWriteMutex;
boost::condition_variable mWriteCondition;
int mWriteGeneration;
int mWriteLoad;
std::vector< boost::shared_ptr<HashedObject> > mWriteSet;
bool mWritePending;
bool mLevelDB;
bool mEphemeralDB;
};
#endif

View File

@@ -51,13 +51,6 @@ enum JobType
class Job
{
protected:
JobType mType;
uint64 mJobIndex;
FUNCTION_TYPE<void(Job&)> 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<void(Job&)> 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<void(Job&)>& 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<JobType, std::pair<int, int> > > 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<LoadEvent>(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<void(Job&)>& 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<JobType, std::pair<int, int> > > 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<LoadEvent>(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

View File

@@ -43,6 +43,7 @@ class SqliteStatement;
class Ledger : public boost::enable_shared_from_this<Ledger>, 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)

View File

@@ -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<uint64, int> 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<uint64, int> 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<PeerSet>, const boost::system::error_code& result);
static void TimerJobEntry(Job&, boost::shared_ptr<PeerSet>);

View File

@@ -19,9 +19,12 @@
DEFINE_INSTANCE(LedgerConsensus);
DEFINE_INSTANCE(TransactionAcquire);
class TransactionAcquire :
private IS_INSTANCE(TransactionAcquire), public PeerSet, public boost::enable_shared_from_this<TransactionAcquire>
{ // 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 <TransactionAcquire>
{
public:
typedef boost::shared_ptr<TransactionAcquire> pointer;
@@ -37,7 +40,6 @@ protected:
boost::weak_ptr<PeerSet> pmDowncast();
public:
TransactionAcquire(const uint256& hash);
virtual ~TransactionAcquire() { ; }

View File

@@ -49,30 +49,7 @@ public:
class LedgerEntrySet : private IS_INSTANCE(LedgerEntrySet)
{
protected:
Ledger::pointer mLedger;
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
TransactionMetaSet mSet;
TransactionEngineParams mParams;
int mSeq;
bool mImmutable;
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &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<uint256, SLE::pointer>& newMods);
bool threadTx(const RippleAddress& threadTo, Ledger::ref ledger,
boost::unordered_map<uint256, SLE::pointer>& newMods);
bool threadTx(SLE::ref threadTo, Ledger::ref ledger, boost::unordered_map<uint256, SLE::pointer>& newMods);
bool threadOwners(SLE::ref node, Ledger::ref ledger, boost::unordered_map<uint256, SLE::pointer>& 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<uint256, LedgerEntrySetEntry>::iterator end() { return mEntries.end(); }
static bool intersect(const LedgerEntrySet& lesLeft, const LedgerEntrySet& lesRight);
private:
Ledger::pointer mLedger;
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
TransactionMetaSet mSet;
TransactionEngineParams mParams;
int mSeq;
bool mImmutable;
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &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<uint256, SLE::pointer>& newMods);
bool threadTx(const RippleAddress& threadTo, Ledger::ref ledger,
boost::unordered_map<uint256, SLE::pointer>& newMods);
bool threadTx(SLE::ref threadTo, Ledger::ref ledger, boost::unordered_map<uint256, SLE::pointer>& newMods);
bool threadOwners(SLE::ref node, Ledger::ref ledger, boost::unordered_map<uint256, SLE::pointer>& newMods);
};
inline LedgerEntrySet::iterator range_begin(LedgerEntrySet& x) { return x.begin(); }

View File

@@ -18,49 +18,7 @@ class LedgerMaster
public:
typedef FUNCTION_TYPE<void(Ledger::ref)> 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<callback> mOnValidate; // Called when a ledger has enough validations
std::list<Ledger::pointer> 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<callback> mOnValidate; // Called when a ledger has enough validations
std::list<Ledger::pointer> mPubLedgers; // List of ledgers to publish
bool mPubThread; // Publish thread is running
bool mPathFindThread; // Pathfind thread is running
bool mPathFindNewLedger;
bool mPathFindNewRequest;
};
#endif

View File

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

View File

@@ -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<LoadCost> mCosts;
void addLoadCost(const LoadCost& c) { mCosts[static_cast<int>(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<int>(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<LoadCost> mCosts;
void addLoadCost(const LoadCost& c) { mCosts[static_cast<int>(c.mType)] = c; }
void threadEntry();
};
#endif

View File

@@ -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<LoadEvent> pointer;
typedef UPTR_T<LoadEvent> 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<int>((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds()));
}
private:
LoadMonitor& mMonitor;
bool mRunning;
std::string mName;
boost::posix_time::ptime mStartTime;
};
#endif

View File

@@ -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<RippleAddress> mSubAccountInfo;
boost::unordered_set<RippleAddress> mSubAccountTransaction;
boost::shared_ptr<PFRequest> mPFRequest;
boost::mutex mLockInfo;
uint64 mSeq;
static uint64 sSeq;
static boost::mutex sSeqLock;
public:
typedef boost::shared_ptr<InfoSub> pointer;
typedef boost::weak_ptr<InfoSub> wptr;
@@ -83,6 +73,19 @@ public:
{
return mPFRequest;
}
protected:
// VFALCO: TODO, make accessor for this member
boost::mutex mLockInfo;
private:
boost::unordered_set<RippleAddress> mSubAccountInfo;
boost::unordered_set<RippleAddress> mSubAccountTransaction;
boost::shared_ptr<PFRequest> mPFRequest;
uint64 mSeq;
static uint64 sSeq;
static boost::mutex sSeqLock;
};
class NetworkOPs
@@ -105,69 +108,6 @@ public:
typedef boost::unordered_map<uint64, InfoSub::wptr> subMapType;
protected:
typedef boost::unordered_map<uint160, subMapType> subInfoMapType;
typedef boost::unordered_map<uint160, subMapType>::value_type subInfoMapValue;
typedef boost::unordered_map<uint160, subMapType>::iterator subInfoMapIterator;
typedef boost::unordered_map<std::string, InfoSub::pointer> subRpcMapType;
OperatingMode mMode;
bool mNeedNetworkLedger;
bool mProposing, mValidating;
bool mFeatureBlocked;
boost::posix_time::ptime mConnectTime;
boost::asio::deadline_timer mNetTimer;
boost::shared_ptr<LedgerConsensus> mConsensus;
boost::unordered_map<uint160,
std::list<LedgerProposal::pointer> > 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<uint256, std::pair<int, SHAMap::pointer> > 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<unsigned char>, 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<unsigned char>& 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<uint160, subMapType> subInfoMapType;
typedef boost::unordered_map<uint160, subMapType>::value_type subInfoMapValue;
typedef boost::unordered_map<uint160, subMapType>::iterator subInfoMapIterator;
typedef boost::unordered_map<std::string, InfoSub::pointer> subRpcMapType;
OperatingMode mMode;
bool mNeedNetworkLedger;
bool mProposing, mValidating;
bool mFeatureBlocked;
boost::posix_time::ptime mConnectTime;
boost::asio::deadline_timer mNetTimer;
boost::shared_ptr<LedgerConsensus> mConsensus;
boost::unordered_map<uint160,
std::list<LedgerProposal::pointer> > 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<uint256, std::pair<int, SHAMap::pointer> > 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<unsigned char>, 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

View File

@@ -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<uint256> usOfferUnfundedFound; // Offers found unfunded.
public:
OfferCreateTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine) : Transactor(txn,params,engine) {}
TER doApply();
};
#endif
// vim:ts=4

View File

@@ -34,8 +34,23 @@ public:
typedef const wptr& wref;
typedef std::pair<uint160, uint160> currIssuer_t;
public:
PFRequest(const boost::shared_ptr<InfoSub>& subscriber);
protected:
bool isValid(const boost::shared_ptr<Ledger>&);
bool isValid();
bool isNew();
Json::Value getStatus();
Json::Value doCreate(const boost::shared_ptr<Ledger>&, const Json::Value&);
Json::Value doClose(const Json::Value&);
Json::Value doStatus(const Json::Value&);
bool doUpdate(const boost::shared_ptr<RLCache>&, bool fast); // update jvStatus
static void updateAll(const boost::shared_ptr<Ledger>& ledger, bool newOnly);
private:
boost::recursive_mutex mLock;
boost::weak_ptr<InfoSub> 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<InfoSub>& subscriber);
bool isValid(const boost::shared_ptr<Ledger>&);
bool isValid();
bool isNew();
Json::Value getStatus();
Json::Value doCreate(const boost::shared_ptr<Ledger>&, const Json::Value&);
Json::Value doClose(const Json::Value&);
Json::Value doStatus(const Json::Value&);
bool doUpdate(const boost::shared_ptr<RLCache>&, bool fast); // update jvStatus
static void updateAll(const boost::shared_ptr<Ledger>& ledger, bool newOnly);
};
#endif

View File

@@ -13,10 +13,6 @@ public:
typedef boost::shared_ptr<Parameter> pointer;
typedef const boost::shared_ptr<Parameter>& 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<std::string, Parameter::pointer> 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<std::string, Parameter::pointer> 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

View File

@@ -36,11 +36,6 @@ public:
class RLCache
{
protected:
boost::mutex mLock;
Ledger::pointer mLedger;
boost::unordered_map<uint160, AccountItems::pointer> mRLMap;
public:
typedef boost::shared_ptr<RLCache> 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<uint160, AccountItems::pointer> 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<uint160> usAccountDestCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger,

View File

@@ -61,7 +61,6 @@ private:
void handlePingTimer(const boost::system::error_code& ecResult);
protected:
boost::asio::io_service::strand mIOStrand;
std::vector<uint8_t> mReadbuf;
std::list<PackedMessage::pointer> mSendQ;

View File

@@ -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<time_t>, boost::bimaps::unordered_set_of<uint256> > 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

View File

@@ -133,18 +133,19 @@ 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);
};
// VFALCO: TODO, tidy up this loose function
int iAdminGet (const Json::Value& jvRequest, const std::string& strRemoteIp);
#endif

View File

@@ -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<std::pair<int, Json::Value> > mDeque;
protected:
void sendThread();
public:
typedef boost::shared_ptr<RPCSub> 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<std::pair<int, Json::Value> > mDeque;
};
#endif

View File

@@ -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<PathState> pointer;
typedef const boost::shared_ptr<PathState>& 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<PathState::pointer>& vpsExpanded, bool bKeepDefault);
protected:
LedgerEntrySet& lesActive;
bool mOpenLedger;
};
#endif

View File

@@ -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<SHAMap> pointer;
typedef const boost::shared_ptr<SHAMap>& ref;
@@ -338,48 +339,7 @@ public:
typedef std::map<uint256, SHAMapDiffItem> SHAMapDiff;
typedef boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer> SHADirtyMap;
protected:
uint32 mSeq;
uint32 mLedgerSeq; // sequence number of ledger this is part of
mutable boost::recursive_mutex mLock;
boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer> mTNByID;
boost::shared_ptr<SHADirtyMap> mDirtyNodes;
SHAMapTreeNode::pointer root;
SHAMapState mState;
SHAMapType mType;
static KeyCache <uint256, UptimeTimerAdapter> fullBelowCache;
void dirtyUp(std::stack<SHAMapTreeNode::pointer>& stack, const uint256& target, uint256 prevHash);
std::stack<SHAMapTreeNode::pointer> 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<fetchPackEntry_t> 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<SHAMapNode, SHAMapTreeNode::pointer> mTNByID;
boost::shared_ptr<SHADirtyMap> mDirtyNodes;
SHAMapTreeNode::pointer root;
SHAMapState mState;
SHAMapType mType;
static KeyCache <uint256, UptimeTimerAdapter> fullBelowCache;
void dirtyUp(std::stack<SHAMapTreeNode::pointer>& stack, const uint256& target, uint256 prevHash);
std::stack<SHAMapTreeNode::pointer> 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

View File

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

View File

@@ -21,7 +21,16 @@ public:
class SNTPClient
{
protected:
public:
SNTPClient(boost::asio::io_service& service);
void init(const std::vector<std::string>& servers);
void addServer(const std::string& mServer);
void queryAll();
bool doQuery();
bool getOffset(int& offset);
private:
std::map<boost::asio::ip::udp::endpoint, SNTPQuery> 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<std::string>& servers);
void addServer(const std::string& mServer);
void queryAll();
bool doQuery();
bool getOffset(int& offset);
};
#endif

View File

@@ -13,14 +13,6 @@ public:
typedef boost::shared_ptr<SerializedLedgerEntry> pointer;
typedef const boost::shared_ptr<SerializedLedgerEntry>& 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<uint256> 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;

View File

@@ -23,27 +23,19 @@ public:
class SOTemplate
{
protected:
std::vector<const SOElement*> mTypes;
std::vector<int> mIndex; // field num -> index
public:
SOTemplate() { ; }
const std::vector<const SOElement*>& peek() const { return mTypes; }
void push_back(const SOElement& r);
int getIndex(SField::ref) const;
private:
std::vector<const SOElement*> mTypes;
std::vector<int> mIndex; // field num -> index
};
class STObject : public SerializedType, private IS_INSTANCE(SerializedObject)
{
protected:
boost::ptr_vector<SerializedType> mData;
const SOTemplate* mType;
STObject* duplicate() const { return new STObject(*this); }
STObject(SField::ref name, boost::ptr_vector<SerializedType>& 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<SerializedType> mData;
const SOTemplate* mType;
STObject* duplicate() const { return new STObject(*this); }
STObject(SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType(name), mType(NULL)
{ mData.swap(data); }
};
// allow ptr_* collections of STObject's
@@ -202,15 +202,7 @@ public:
typedef boost::ptr_vector<STObject>::const_reverse_iterator const_reverse_iterator;
typedef boost::ptr_vector<STObject>::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(); }

View File

@@ -23,14 +23,6 @@ public:
typedef boost::shared_ptr<SerializedTransaction> pointer;
typedef const boost::shared_ptr<SerializedTransaction>& 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

View File

@@ -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,10 +192,14 @@ 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);
};
class STAmount : public SerializedType
{
// Internal form:
// 1: If amount is zero, then value is zero and offset is -100
// 2: Otherwise:
@@ -210,52 +210,8 @@ class STAmount : public SerializedType
// 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)
class STAmount : public SerializedType
{
if (v < 0)
{
mIsNegative = true;
mValue = static_cast<uint64>(-v);
}
else
{
mIsNegative = false;
mValue = static_cast<uint64>(v);
}
}
void set(int v)
{
if (v < 0)
{
mIsNegative = true;
mValue = static_cast<uint64>(-v);
}
else
{
mIsNegative = false;
mValue = static_cast<uint64>(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<uint64>(-v);
}
else
{
mIsNegative = false;
mValue = static_cast<uint64>(v);
}
}
void set(int v)
{
if (v < 0)
{
mIsNegative = true;
mValue = static_cast<uint64>(-v);
}
else
{
mIsNegative = false;
mValue = static_cast<uint64>(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<unsigned char> value;
virtual STVariableLength* duplicate() const { return new STVariableLength(*this); }
static STVariableLength* construct(SerializerIterator&, SField::ref);
{
public:
STVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
STVariableLength(SField::ref n, const std::vector<unsigned char>& v) : SerializedType(n), value(v) { ; }
STVariableLength(SField::ref n) : SerializedType(n) { ; }
@@ -597,16 +589,17 @@ public:
operator std::vector<unsigned char>() const { return value; }
virtual bool isEquivalent(const SerializedType& t) const;
virtual bool isDefault() const { return value.empty(); }
private:
std::vector<unsigned char> 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<unsigned char>& v) : STVariableLength(v) { ; }
STAccount(SField::ref n, const std::vector<unsigned char>& 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
{
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<STPathElement> mPath;
public:
STPath() { ; }
STPath(const std::vector<STPathElement>& 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<STPathElement> mPath;
};
inline std::vector<STPathElement>::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<STPath> 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<STPath>& v) : value(v) { ; }
explicit STPathSet(SField::ref n) : SerializedType(n) { ; }
explicit STPathSet(const std::vector<STPath>& v) : value(v) { ; }
STPathSet(SField::ref n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
{ return UPTR_T<SerializedType>(construct(sit, name)); }
{
return UPTR_T<SerializedType>(construct(sit, name));
}
// std::string getText() const;
void add(Serializer& s) const;
@@ -791,6 +793,12 @@ public:
std::vector<STPath>::iterator end() { return value.end(); }
std::vector<STPath>::const_iterator begin() const { return value.begin(); }
std::vector<STPath>::const_iterator end() const { return value.end(); }
private:
std::vector<STPath> value;
STPathSet* duplicate() const { return new STPathSet(*this); }
static STPathSet* construct(SerializerIterator&, SField::ref);
};
inline std::vector<STPath>::iterator range_begin(STPathSet & x)
@@ -830,12 +838,6 @@ namespace boost
class STVector256 : public SerializedType
{
protected:
std::vector<uint256> 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<uint256> mValue;
STVector256* duplicate() const { return new STVector256(*this); }
static STVector256* construct(SerializerIterator&, SField::ref);
};
#endif

View File

@@ -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<SerializedValidation> pointer;
typedef const boost::shared_ptr<SerializedValidation>& 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

View File

@@ -7,11 +7,7 @@
class TransactionMaster
{
protected:
TaggedCache<uint256, Transaction, UptimeTimerAdapter> 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 <uint256, Transaction, UptimeTimerAdapter> mCache;
};
#endif

View File

@@ -17,14 +17,6 @@ public:
typedef boost::shared_ptr<TransactionMetaSet> pointer;
typedef const pointer& ref;
protected:
uint256 mTransactionID;
uint32 mLedger;
uint32 mIndex;
int mResult;
STArray mNodes;
public:
TransactionMetaSet() : mLedger(0), mIndex(static_cast<uint32>(-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

View File

@@ -16,20 +16,11 @@ class TXQeueue;
class TXQEntry
{
friend class TXQueue;
public:
typedef boost::shared_ptr<TXQEntry> pointer;
typedef const boost::shared_ptr<TXQEntry>& ref;
typedef FUNCTION_TYPE<void (Transaction::pointer, TER)> stCallback; // must complete immediately
protected:
Transaction::pointer mTxn;
bool mSigChecked;
std::list<stCallback> 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<stCallback> mCallbacks;
void addCallbacks(const TXQEntry& otherEntry);
};
class TXQueue
{
protected:
typedef boost::bimaps::unordered_set_of<uint256> leftType;
typedef boost::bimaps::list_of<TXQEntry::pointer> rightType;
typedef boost::bimap<leftType, rightType> 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<uint256> leftType;
typedef boost::bimaps::list_of<TXQEntry::pointer> rightType;
typedef boost::bimap<leftType, rightType> mapType;
typedef mapType::value_type valueType;
mapType mTxMap;
bool mRunning;
boost::mutex mLock;
};
#endif

View File

@@ -9,6 +9,13 @@
class Transactor
{
public:
typedef boost::shared_ptr<Transactor> pointer;
static UPTR_T<Transactor> 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<Transactor> pointer;
static UPTR_T<Transactor> makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine);
TER apply();
};
#endif

View File

@@ -37,23 +37,6 @@ public:
typedef typename boost::weak_ptr<connection> weak_connection_ptr;
typedef typename endpoint_type::handler::message_ptr message_ptr;
protected:
typedef void (WSConnection::*doFuncPtr)(Json::Value& jvResult, Json::Value &jvRequest);
WSServerHandler<endpoint_type>* 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<message_ptr> mRcvQueue;
bool mRcvQueueRunning;
bool mDead;
public:
// WSConnection()
// : mHandler((WSServerHandler<websocketpp::WSDOOR_SERVER>*)(NULL)),
@@ -254,6 +237,22 @@ public:
return m;
}
private:
typedef void (WSConnection::*doFuncPtr)(Json::Value& jvResult, Json::Value &jvRequest);
WSServerHandler<endpoint_type>* 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<message_ptr> mRcvQueue;
bool mRcvQueueRunning;
bool mDead;
};
// vim:ts=4

View File

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

View File

@@ -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<uint64> 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<uint64>& s) { mPeers.swap(s); }
protected:
int mFlags;
std::set<uint64> mPeers;
};
class IHashRouter