Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-10-22 16:16:07 -07:00
29 changed files with 141 additions and 71 deletions

View File

@@ -70,8 +70,9 @@ void Application::run()
{ {
assert(mTxnDB == NULL); assert(mTxnDB == NULL);
if (!theConfig.DEBUG_LOGFILE.empty()) if (!theConfig.DEBUG_LOGFILE.empty())
{ { // Let DEBUG messages go to the file but only WARNING or higher to regular output
Log::setLogFile(theConfig.DEBUG_LOGFILE); Log::setLogFile(theConfig.DEBUG_LOGFILE);
Log::setMinSeverity(lsWARNING);
LogPartition::setSeverity(lsDEBUG); LogPartition::setSeverity(lsDEBUG);
} }
@@ -112,6 +113,13 @@ void Application::run()
else else
startNewLedger(); startNewLedger();
if (theConfig.FULL_HISTORY && (theConfig.START_UP != Config::LOAD))
{
Ledger::pointer ledger = Ledger::getLastFullLedger();
if (ledger)
mMasterLedger.setLastFullLedger(ledger);
}
// //
// Begin validation and ip maintenance. // Begin validation and ip maintenance.
// - Wallet maintains local information: including identity and network connection persistence information. // - Wallet maintains local information: including identity and network connection persistence information.
@@ -214,7 +222,7 @@ void Application::loadOldLedger()
{ {
try try
{ {
Ledger::pointer lastLedger = Ledger::getSQL("SELECT * from Ledgers order by LedgerSeq desc limit 1;"); Ledger::pointer lastLedger = Ledger::getLastFullLedger();
if (!lastLedger) if (!lastLedger)
{ {
@@ -243,6 +251,7 @@ void Application::loadOldLedger()
cLog(lsFATAL) << "Ledger is not sane."; cLog(lsFATAL) << "Ledger is not sane.";
exit(-1); exit(-1);
} }
mMasterLedger.setLastFullLedger(lastLedger);
Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*lastLedger)); Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*lastLedger));
mMasterLedger.switchLedgers(lastLedger, openLedger); mMasterLedger.switchLedgers(lastLedger, openLedger);

View File

@@ -37,7 +37,7 @@ bool CanonicalTXKey::operator>=(const CanonicalTXKey& key)const
return mTXid >= key.mTXid; return mTXid >= key.mTXid;
} }
void CanonicalTXSet::push_back(const SerializedTransaction::pointer& txn) void CanonicalTXSet::push_back(SerializedTransaction::ref txn)
{ {
uint256 effectiveAccount = mSetHash; uint256 effectiveAccount = mSetHash;
effectiveAccount ^= txn->getSourceAccount().getAccountID().to256(); effectiveAccount ^= txn->getSourceAccount().getAccountID().to256();

View File

@@ -38,7 +38,7 @@ protected:
public: public:
CanonicalTXSet(const uint256& lclHash) : mSetHash(lclHash) { ; } CanonicalTXSet(const uint256& lclHash) : mSetHash(lclHash) { ; }
void push_back(const SerializedTransaction::pointer& txn); void push_back(SerializedTransaction::ref txn);
iterator erase(const iterator& it); iterator erase(const iterator& it);
iterator begin() { return mMap.begin(); } iterator begin() { return mMap.begin(); }

View File

@@ -14,6 +14,7 @@
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create" #define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
#define SECTION_FEE_OFFER "fee_offer" #define SECTION_FEE_OFFER "fee_offer"
#define SECTION_FEE_OPERATION "fee_operation" #define SECTION_FEE_OPERATION "fee_operation"
#define SECTION_FULL_HISTORY "full_history"
#define SECTION_IPS "ips" #define SECTION_IPS "ips"
#define SECTION_NETWORK_QUORUM "network_quorum" #define SECTION_NETWORK_QUORUM "network_quorum"
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water" #define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
@@ -150,6 +151,8 @@ void Config::setup(const std::string& strConf)
FEE_DEFAULT = DEFAULT_FEE_DEFAULT; FEE_DEFAULT = DEFAULT_FEE_DEFAULT;
FEE_CONTRACT_OPERATION = DEFAULT_FEE_OPERATION; FEE_CONTRACT_OPERATION = DEFAULT_FEE_OPERATION;
FULL_HISTORY = false;
ACCOUNT_PROBE_MAX = 10; ACCOUNT_PROBE_MAX = 10;
VALIDATORS_SITE = DEFAULT_VALIDATORS_SITE; VALIDATORS_SITE = DEFAULT_VALIDATORS_SITE;
@@ -266,6 +269,9 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_FEE_OPERATION, strTemp)) if (sectionSingleB(secConfig, SECTION_FEE_OPERATION, strTemp))
FEE_CONTRACT_OPERATION = boost::lexical_cast<int>(strTemp); FEE_CONTRACT_OPERATION = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_FULL_HISTORY, strTemp))
FULL_HISTORY = boost::lexical_cast<bool>(strTemp);
if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) if (sectionSingleB(secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
ACCOUNT_PROBE_MAX = boost::lexical_cast<int>(strTemp); ACCOUNT_PROBE_MAX = boost::lexical_cast<int>(strTemp);

View File

@@ -102,6 +102,9 @@ public:
uint64 FEE_OFFER; // Rate per day. uint64 FEE_OFFER; // Rate per day.
int FEE_CONTRACT_OPERATION; // fee for each contract operation int FEE_CONTRACT_OPERATION; // fee for each contract operation
// Node storage configuration
bool FULL_HISTORY;
// Client behavior // Client behavior
int ACCOUNT_PROBE_MAX; // How far to scan for accounts. int ACCOUNT_PROBE_MAX; // How far to scan for accounts.

View File

@@ -429,6 +429,12 @@ void Ledger::saveAcceptedLedger()
} }
theApp->getOPs().pubLedger(shared_from_this()); theApp->getOPs().pubLedger(shared_from_this());
if(theConfig.FULL_HISTORY)
{
// WRITEME: check for seamless ledger history
}
} }
Ledger::pointer Ledger::getSQL(const std::string& sql) Ledger::pointer Ledger::getSQL(const std::string& sql)
@@ -498,6 +504,11 @@ Ledger::pointer Ledger::loadByHash(const uint256& ledgerHash)
return getSQL(sql); return getSQL(sql);
} }
Ledger::pointer Ledger::getLastFullLedger()
{
return getSQL("SELECT * from Ledgers order by LedgerSeq desc limit 1;");
}
void Ledger::addJson(Json::Value& ret, int options) void Ledger::addJson(Json::Value& ret, int options)
{ {
ret["ledger"] = getJson(options); ret["ledger"] = getJson(options);

View File

@@ -100,6 +100,7 @@ public:
Ledger(Ledger& target, bool isMutable); // snapshot Ledger(Ledger& target, bool isMutable); // snapshot
static Ledger::pointer getSQL(const std::string& sqlStatement); static Ledger::pointer getSQL(const std::string& sqlStatement);
static Ledger::pointer getLastFullLedger();
void updateHash(); void updateHash();
void setClosed() { mClosed = true; } void setClosed() { mClosed = true; }

View File

@@ -326,6 +326,29 @@ void PeerSet::sendRequest(const ripple::TMGetLedger& tmGL)
} }
} }
int PeerSet::takePeerSetFrom(const PeerSet& s)
{
int ret = 0;
mPeers.clear();
mPeers.reserve(s.mPeers.size());
BOOST_FOREACH(const boost::weak_ptr<Peer>& p, s.mPeers)
if (p.lock())
{
mPeers.push_back(p);
++ret;
}
return ret;
}
int PeerSet::getPeerCount() const
{
int ret = 0;
BOOST_FOREACH(const boost::weak_ptr<Peer>& p, mPeers)
if (p.lock())
++ret;
return ret;
}
bool LedgerAcquire::takeBase(const std::string& data) bool LedgerAcquire::takeBase(const std::string& data)
{ // Return value: true=normal, false=bad data { // Return value: true=normal, false=bad data
#ifdef LA_DEBUG #ifdef LA_DEBUG

View File

@@ -45,6 +45,9 @@ public:
void badPeer(Peer::ref); void badPeer(Peer::ref);
void resetTimer(); void resetTimer();
int takePeerSetFrom(const PeerSet& s);
int getPeerCount() const;
protected: protected:
virtual void newPeer(Peer::ref) = 0; virtual void newPeer(Peer::ref) = 0;
virtual void onTimer(void) = 0; virtual void onTimer(void) = 0;

View File

@@ -993,7 +993,7 @@ void LedgerConsensus::playbackProposals()
} }
} }
void LedgerConsensus::applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn, void LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn,
Ledger::ref ledger, CanonicalTXSet& failedTransactions, bool openLedger) Ledger::ref ledger, CanonicalTXSet& failedTransactions, bool openLedger)
{ {
TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE; TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE;

View File

@@ -134,7 +134,7 @@ protected:
void sendHaveTxSet(const uint256& set, bool direct); void sendHaveTxSet(const uint256& set, bool direct);
void applyTransactions(SHAMap::ref transactionSet, Ledger::ref targetLedger, void applyTransactions(SHAMap::ref transactionSet, Ledger::ref targetLedger,
Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr); Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr);
void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn, void applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn,
Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr); Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr);
uint32 roundCloseTime(uint32 closeTime); uint32 roundCloseTime(uint32 closeTime);

View File

@@ -66,7 +66,7 @@ public:
void clear(); void clear();
Ledger::pointer& getLedger() { return mLedger; } Ledger::pointer& getLedger() { return mLedger; }
const Ledger::pointer& getLedgerRef() const { return mLedger; } Ledger::ref getLedgerRef() const { return mLedger; }
// basic entry functions // basic entry functions
SLE::pointer getEntry(const uint256& index, LedgerEntryAction&); SLE::pointer getEntry(const uint256& index, LedgerEntryAction&);

View File

@@ -32,6 +32,8 @@ void LedgerMaster::pushLedger(Ledger::ref newLedger)
mFinalizedLedger = mCurrentLedger; mFinalizedLedger = mCurrentLedger;
mCurrentLedger = newLedger; mCurrentLedger = newLedger;
mEngine.setLedger(newLedger); mEngine.setLedger(newLedger);
if (mLastFullLedger && (newLedger->getParentHash() == mLastFullLedger->getHash()))
mLastFullLedger = newLedger;
} }
void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL) void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL)
@@ -44,6 +46,8 @@ void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL)
assert(newLCL->isClosed()); assert(newLCL->isClosed());
assert(newLCL->isImmutable()); assert(newLCL->isImmutable());
mLedgerHistory.addAcceptedLedger(newLCL); mLedgerHistory.addAcceptedLedger(newLCL);
if (mLastFullLedger && (newLCL->getParentHash() == mLastFullLedger->getHash()))
mLastFullLedger = newLCL;
Log(lsINFO) << "StashAccepted: " << newLCL->getHash(); Log(lsINFO) << "StashAccepted: " << newLCL->getHash();
} }

View File

@@ -20,6 +20,7 @@ class LedgerMaster
Ledger::pointer mCurrentLedger; // The ledger we are currently processiong Ledger::pointer mCurrentLedger; // The ledger we are currently processiong
Ledger::pointer mFinalizedLedger; // The ledger that most recently closed Ledger::pointer mFinalizedLedger; // The ledger that most recently closed
Ledger::pointer mLastFullLedger; // We have history to this point
LedgerHistory mLedgerHistory; LedgerHistory mLedgerHistory;
@@ -49,6 +50,11 @@ public:
void pushLedger(Ledger::ref newLCL, Ledger::ref newOL); void pushLedger(Ledger::ref newLCL, Ledger::ref newOL);
void storeLedger(Ledger::ref); void storeLedger(Ledger::ref);
void setLastFullLedger(Ledger::ref ledger)
{
mLastFullLedger = ledger;
}
void switchLedgers(Ledger::ref lastClosed, Ledger::ref newCurrent); void switchLedgers(Ledger::ref lastClosed, Ledger::ref newCurrent);
Ledger::pointer closeLedger(); Ledger::pointer closeLedger();

View File

@@ -496,7 +496,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
ValidationCount& ourVC = ledgers[closedLedger]; ValidationCount& ourVC = ledgers[closedLedger];
if ((theConfig.LEDGER_CREATOR) && (mMode >= omTRACKING)) if (mMode >= omTRACKING)
{ {
++ourVC.nodesUsing; ++ourVC.nodesUsing;
uint160 ourAddress = theApp->getWallet().getNodePublic().getNodeID(); uint160 ourAddress = theApp->getWallet().getNodePublic().getNodeID();
@@ -638,7 +638,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
theApp->getConnectionPool().relayMessage(NULL, packet); theApp->getConnectionPool().relayMessage(NULL, packet);
} }
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger) int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger)
{ {
cLog(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq(); cLog(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq();
cLog(lsINFO) << " LCL is " << closingLedger->getParentHash(); cLog(lsINFO) << " LCL is " << closingLedger->getParentHash();
@@ -864,7 +864,7 @@ std::vector<NewcoinAddress>
bool NetworkOPs::recvValidation(const SerializedValidation::pointer& val) bool NetworkOPs::recvValidation(const SerializedValidation::pointer& val)
{ {
cLog(lsINFO) << "recvValidation " << val->getLedgerHash(); cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash();
return theApp->getValidations().addValidation(val); return theApp->getValidations().addValidation(val);
} }

View File

@@ -180,7 +180,7 @@ public:
void checkState(const boost::system::error_code& result); void checkState(const boost::system::error_code& result);
void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case
bool checkLastClosedLedger(const std::vector<Peer::pointer>&, uint256& networkClosed); bool checkLastClosedLedger(const std::vector<Peer::pointer>&, uint256& networkClosed);
int beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger); int beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger);
void endConsensus(bool correctLCL); void endConsensus(bool correctLCL);
void setStandAlone() { setMode(omFULL); } void setStandAlone() { setMode(omFULL); }
void setStateTimer(); void setStateTimer();

View File

@@ -1053,8 +1053,6 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet)
ledger->addRaw(nData); ledger->addRaw(nData);
reply.add_nodes()->set_nodedata(nData.getDataPtr(), nData.getLength()); reply.add_nodes()->set_nodedata(nData.getDataPtr(), nData.getLength());
if (packet.nodeids().size() != 0)
{ // new-style root request
cLog(lsINFO) << "Ledger root w/map roots request"; cLog(lsINFO) << "Ledger root w/map roots request";
SHAMap::pointer map = ledger->peekAccountStateMap(); SHAMap::pointer map = ledger->peekAccountStateMap();
if (map && map->getHash().isNonZero()) if (map && map->getHash().isNonZero())
@@ -1075,7 +1073,6 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet)
} }
} }
} }
}
PackedMessage::pointer oPacket = boost::make_shared<PackedMessage>(reply, ripple::mtLEDGER_DATA); PackedMessage::pointer oPacket = boost::make_shared<PackedMessage>(reply, ripple::mtLEDGER_DATA);
sendPacket(oPacket); sendPacket(oPacket);

View File

@@ -27,7 +27,7 @@ std::size_t hash_value(const aciSource& asValue)
// <-- uOfferIndex : 0=end of list. // <-- uOfferIndex : 0=end of list.
TER RippleCalc::calcNodeAdvance( TER RippleCalc::calcNodeAdvance(
const unsigned int uIndex, // 0 < uIndex < uLast const unsigned int uIndex, // 0 < uIndex < uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality, const bool bMultiQuality,
const bool bReverse) const bool bReverse)
{ {
@@ -267,7 +267,7 @@ TER RippleCalc::calcNodeAdvance(
// Continue process till request is satisified while we the rate does not increase past the initial rate. // Continue process till request is satisified while we the rate does not increase past the initial rate.
TER RippleCalc::calcNodeDeliverRev( TER RippleCalc::calcNodeDeliverRev(
const unsigned int uIndex, // 0 < uIndex < uLast const unsigned int uIndex, // 0 < uIndex < uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality, const bool bMultiQuality,
const uint160& uOutAccountID, // --> Output owner's account. const uint160& uOutAccountID, // --> Output owner's account.
const STAmount& saOutReq, // --> Funds wanted. const STAmount& saOutReq, // --> Funds wanted.
@@ -459,7 +459,7 @@ TER RippleCalc::calcNodeDeliverRev(
// Goal: Make progress consuming the offer. // Goal: Make progress consuming the offer.
TER RippleCalc::calcNodeDeliverFwd( TER RippleCalc::calcNodeDeliverFwd(
const unsigned int uIndex, // 0 < uIndex < uLast const unsigned int uIndex, // 0 < uIndex < uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality, const bool bMultiQuality,
const uint160& uInAccountID, // --> Input owner's account. const uint160& uInAccountID, // --> Input owner's account.
const STAmount& saInFunds, // --> Funds available for delivery and fees. const STAmount& saInFunds, // --> Funds available for delivery and fees.
@@ -610,7 +610,7 @@ TER RippleCalc::calcNodeDeliverFwd(
// Called to drive from the last offer node in a chain. // Called to drive from the last offer node in a chain.
TER RippleCalc::calcNodeOfferRev( TER RippleCalc::calcNodeOfferRev(
const unsigned int uIndex, // 0 < uIndex < uLast const unsigned int uIndex, // 0 < uIndex < uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality) const bool bMultiQuality)
{ {
TER terResult; TER terResult;
@@ -650,7 +650,7 @@ TER RippleCalc::calcNodeOfferRev(
// - Deliver is set without transfer fees. // - Deliver is set without transfer fees.
TER RippleCalc::calcNodeOfferFwd( TER RippleCalc::calcNodeOfferFwd(
const unsigned int uIndex, // 0 < uIndex < uLast const unsigned int uIndex, // 0 < uIndex < uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality const bool bMultiQuality
) )
{ {
@@ -789,7 +789,7 @@ void RippleCalc::calcNodeRipple(
// Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver from saCur... // Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver from saCur...
// <-- tesSUCCESS or tepPATH_DRY // <-- tesSUCCESS or tepPATH_DRY
TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
{ {
TER terResult = tesSUCCESS; TER terResult = tesSUCCESS;
const unsigned int uLast = pspCur->vpnNodes.size() - 1; const unsigned int uLast = pspCur->vpnNodes.size() - 1;
@@ -1100,7 +1100,7 @@ TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::p
// - Output to next node is computed as input minus quality or transfer fee. // - Output to next node is computed as input minus quality or transfer fee.
TER RippleCalc::calcNodeAccountFwd( TER RippleCalc::calcNodeAccountFwd(
const unsigned int uIndex, // 0 <= uIndex <= uLast const unsigned int uIndex, // 0 <= uIndex <= uLast
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality) const bool bMultiQuality)
{ {
TER terResult = tesSUCCESS; TER terResult = tesSUCCESS;
@@ -1362,7 +1362,7 @@ TER RippleCalc::calcNodeAccountFwd(
} }
// Return true, iff lhs has less priority than rhs. // Return true, iff lhs has less priority than rhs.
bool PathState::lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs) bool PathState::lessPriority(PathState::ref lhs, PathState::ref rhs)
{ {
if (lhs->uQuality != rhs->uQuality) if (lhs->uQuality != rhs->uQuality)
return lhs->uQuality > rhs->uQuality; // Bigger is worse. return lhs->uQuality > rhs->uQuality; // Bigger is worse.
@@ -1713,7 +1713,7 @@ Json::Value PathState::getJson() const
return jvPathState; return jvPathState;
} }
TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) TER RippleCalc::calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
{ {
const PaymentNode& pnCur = pspCur->vpnNodes[uIndex]; const PaymentNode& pnCur = pspCur->vpnNodes[uIndex];
const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount); const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount);
@@ -1743,7 +1743,7 @@ TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer&
// --> [all]saWanted.mCurrency // --> [all]saWanted.mCurrency
// --> [all]saAccount // --> [all]saAccount
// <-> [0]saWanted.mAmount : --> limit, <-- actual // <-> [0]saWanted.mAmount : --> limit, <-- actual
TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) TER RippleCalc::calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
{ {
PaymentNode& pnCur = pspCur->vpnNodes[uIndex]; PaymentNode& pnCur = pspCur->vpnNodes[uIndex];
const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount); const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount);
@@ -1785,7 +1785,7 @@ TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer&
// Calculate the next increment of a path. // Calculate the next increment of a path.
// The increment is what can satisfy a portion or all of the requested output at the best quality. // The increment is what can satisfy a portion or all of the requested output at the best quality.
// <-- pspCur->uQuality // <-- pspCur->uQuality
void RippleCalc::pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent) void RippleCalc::pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent)
{ {
// The next state is what is available in preference order. // The next state is what is available in preference order.
// This is calculated when referenced accounts changed. // This is calculated when referenced accounts changed.

View File

@@ -65,13 +65,14 @@ extern std::size_t hash_value(const aciSource& asValue);
class PathState class PathState
{ {
protected: protected:
const Ledger::pointer& mLedger; Ledger::ref mLedger;
TER pushNode(const int iType, const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); 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); TER pushImply(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID);
public: public:
typedef boost::shared_ptr<PathState> pointer; typedef boost::shared_ptr<PathState> pointer;
typedef const boost::shared_ptr<PathState>& ref;
TER terStatus; TER terStatus;
std::vector<PaymentNode> vpnNodes; std::vector<PaymentNode> vpnNodes;
@@ -123,7 +124,7 @@ public:
return boost::make_shared<PathState>(iIndex, lesSource, spSourcePath, uReceiverID, uSenderID, saSend, saSendMax); return boost::make_shared<PathState>(iIndex, lesSource, spSourcePath, uReceiverID, uSenderID, saSend, saSendMax);
} }
static bool lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs); static bool lessPriority(PathState::ref lhs, PathState::ref rhs);
}; };
class RippleCalc class RippleCalc
@@ -139,18 +140,18 @@ public:
boost::unordered_set<uint256> musUnfundedFound; // Offers that were found unfunded. boost::unordered_set<uint256> musUnfundedFound; // Offers that were found unfunded.
PathState::pointer pathCreate(const STPath& spPath); PathState::pointer pathCreate(const STPath& spPath);
void pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent); void pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent);
TER calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNode(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeOfferRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeOfferRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeOfferFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeOfferFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeAccountFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); TER calcNodeAccountFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
TER calcNodeAdvance(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality, const bool bReverse); TER calcNodeAdvance(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality, const bool bReverse);
TER calcNodeDeliverRev( TER calcNodeDeliverRev(
const unsigned int uIndex, const unsigned int uIndex,
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality, const bool bMultiQuality,
const uint160& uOutAccountID, const uint160& uOutAccountID,
const STAmount& saOutReq, const STAmount& saOutReq,
@@ -158,7 +159,7 @@ public:
TER calcNodeDeliverFwd( TER calcNodeDeliverFwd(
const unsigned int uIndex, const unsigned int uIndex,
const PathState::pointer& pspCur, PathState::ref pspCur,
const bool bMultiQuality, const bool bMultiQuality,
const uint160& uInAccountID, const uint160& uInAccountID,
const STAmount& saInFunds, const STAmount& saInFunds,

View File

@@ -7,7 +7,7 @@
SETUP_LOG(); SETUP_LOG();
RippleLines::RippleLines(const uint160& accountID, Ledger::pointer ledger) RippleLines::RippleLines(const uint160& accountID, Ledger::ref ledger)
{ {
fillLines(accountID, ledger); fillLines(accountID, ledger);
} }
@@ -25,7 +25,7 @@ RippleLines::RippleLines(const uint160& accountID )
fillLines(accountID,theApp->getMasterLedger().getCurrentLedger()); fillLines(accountID,theApp->getMasterLedger().getCurrentLedger());
} }
void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger) void RippleLines::fillLines(const uint160& accountID, Ledger::ref ledger)
{ {
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID); uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
uint256 currentIndex = rootIndex; uint256 currentIndex = rootIndex;

View File

@@ -9,10 +9,10 @@ It provides a vector so you to easily iterate through them
class RippleLines class RippleLines
{ {
std::vector<RippleState::pointer> mLines; std::vector<RippleState::pointer> mLines;
void fillLines(const uint160& accountID, Ledger::pointer ledger); void fillLines(const uint160& accountID, Ledger::ref ledger);
public: public:
RippleLines(const uint160& accountID, Ledger::pointer ledger); RippleLines(const uint160& accountID, Ledger::ref ledger);
RippleLines(const uint160& accountID ); // looks in the current ledger RippleLines(const uint160& accountID ); // looks in the current ledger
std::vector<RippleState::pointer>& getLines() { return(mLines); } std::vector<RippleState::pointer>& getLines() { return(mLines); }

View File

@@ -208,7 +208,7 @@ public:
bool hasItem() const { return !!mItem; } bool hasItem() const { return !!mItem; }
SHAMapItem::ref peekItem() { return mItem; } SHAMapItem::ref peekItem() { return mItem; }
SHAMapItem::pointer getItem() const; SHAMapItem::pointer getItem() const;
bool setItem(const SHAMapItem::pointer& i, TNType type); bool setItem(SHAMapItem::ref i, TNType type);
const uint256& getTag() const { return mItem->getTag(); } const uint256& getTag() const { return mItem->getTag(); }
const std::vector<unsigned char>& peekData() { return mItem->peekData(); } const std::vector<unsigned char>& peekData() { return mItem->peekData(); }
std::vector<unsigned char> getData() const { return mItem->getData(); } std::vector<unsigned char> getData() const { return mItem->getData(); }

View File

@@ -185,7 +185,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapTreeNode& node, uint32 seq) : SHAMapN
memcpy(mHashes, node.mHashes, sizeof(mHashes)); memcpy(mHashes, node.mHashes, sizeof(mHashes));
} }
SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, const SHAMapItem::pointer& item, TNType type, uint32 seq) : SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::ref item, TNType type, uint32 seq) :
SHAMapNode(node), mItem(item), mSeq(seq), mType(type), mFullBelow(true) SHAMapNode(node), mItem(item), mSeq(seq), mType(type), mFullBelow(true)
{ {
assert(item->peekData().size() >= 12); assert(item->peekData().size() >= 12);
@@ -465,7 +465,7 @@ void SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format)
assert(false); assert(false);
} }
bool SHAMapTreeNode::setItem(const SHAMapItem::pointer& i, TNType type) bool SHAMapTreeNode::setItem(SHAMapItem::ref i, TNType type)
{ {
uint256 hash = getNodeHash(); uint256 hash = getNodeHash();
mType = type; mType = type;

View File

@@ -21,6 +21,7 @@ class SerializedTransaction : public STObject
{ {
public: public:
typedef boost::shared_ptr<SerializedTransaction> pointer; typedef boost::shared_ptr<SerializedTransaction> pointer;
typedef const boost::shared_ptr<SerializedTransaction>& ref;
protected: protected:
TransactionType mType; TransactionType mType;

View File

@@ -13,7 +13,7 @@
#include "SerializedTransaction.h" #include "SerializedTransaction.h"
#include "Log.h" #include "Log.h"
Transaction::Transaction(const SerializedTransaction::pointer& sit, bool bValidate) Transaction::Transaction(SerializedTransaction::ref sit, bool bValidate)
: mInLedger(0), mStatus(INVALID), mResult(temUNCERTAIN), mTransaction(sit) : mInLedger(0), mStatus(INVALID), mResult(temUNCERTAIN), mTransaction(sit)
{ {
try try
@@ -709,8 +709,8 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg
for(it = inMap.begin(); it != inMap.end(); ++it) for(it = inMap.begin(); it != inMap.end(); ++it)
{ {
const uint256& id = it->first; const uint256& id = it->first;
const SHAMapItem::pointer& first = it->second.first; SHAMapItem::ref first = it->second.first;
const SHAMapItem::pointer& second = it->second.second; SHAMapItem::ref second = it->second.second;
Transaction::pointer firstTrans, secondTrans; Transaction::pointer firstTrans, secondTrans;
if (!!first) if (!!first)

View File

@@ -129,7 +129,7 @@ private:
const std::vector<unsigned char>& vucSignature); const std::vector<unsigned char>& vucSignature);
public: public:
Transaction(const SerializedTransaction::pointer& st, bool bValidate); Transaction(SerializedTransaction::ref st, bool bValidate);
static Transaction::pointer sharedTransaction(const std::vector<unsigned char>&vucTransaction, bool bValidate); static Transaction::pointer sharedTransaction(const std::vector<unsigned char>&vucTransaction, bool bValidate);
static Transaction::pointer transactionFromSQL(Database* db, bool bValidate); static Transaction::pointer transactionFromSQL(Database* db, bool bValidate);

View File

@@ -31,7 +31,7 @@ Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDi
return txn; return txn;
} }
SerializedTransaction::pointer TransactionMaster::fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger) SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger)
{ {
SerializedTransaction::pointer txn; SerializedTransaction::pointer txn;
Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false); Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false);

View File

@@ -16,7 +16,7 @@ public:
TransactionMaster(); TransactionMaster();
Transaction::pointer fetch(const uint256&, bool checkDisk); Transaction::pointer fetch(const uint256&, bool checkDisk);
SerializedTransaction::pointer fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger); SerializedTransaction::pointer fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger);
// return value: true = we had the transaction already // return value: true = we had the transaction already
bool canonicalize(Transaction::pointer& txn, bool maybeNew); bool canonicalize(Transaction::pointer& txn, bool maybeNew);

View File

@@ -245,15 +245,20 @@ message TMGetLedger {
optional uint32 requestCookie = 6; optional uint32 requestCookie = 6;
} }
enum TMReplyError {
reNO_LEDGER = 1; // We don't have the ledger you are asking about
reNO_NODE = 2; // We don't have any of the nodes you are asking for
}
message TMLedgerData { message TMLedgerData {
required bytes ledgerHash = 1; required bytes ledgerHash = 1;
required uint32 ledgerSeq = 2; required uint32 ledgerSeq = 2;
required TMLedgerInfoType type = 3; required TMLedgerInfoType type = 3;
repeated TMLedgerNode nodes = 4; repeated TMLedgerNode nodes = 4;
optional uint32 requestCookie = 5; optional uint32 requestCookie = 5;
optional TMReplyError error = 6;
} }
message TMPing { message TMPing {
enum pingType { enum pingType {
PING = 0; // we want a reply PING = 0; // we want a reply