mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 00:45:58 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -38,7 +38,7 @@ DatabaseCon::~DatabaseCon()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Application::Application() :
|
Application::Application() :
|
||||||
mIOWork(mIOService), mAuxWork(mAuxService), mUNL(mIOService), mNetOps(mIOService, &mMasterLedger),
|
mIOWork(mIOService), mAuxWork(mAuxService), mUNL(mIOService), mNetOps(mIOService, &mLedgerMaster),
|
||||||
mTempNodeCache("NodeCache", 16384, 90), mHashedObjectStore(16384, 300),
|
mTempNodeCache("NodeCache", 16384, 90), mHashedObjectStore(16384, 300),
|
||||||
mSNTPClient(mAuxService), mRPCHandler(&mNetOps),
|
mSNTPClient(mAuxService), mRPCHandler(&mNetOps),
|
||||||
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
|
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
|
||||||
@@ -122,7 +122,7 @@ void Application::run()
|
|||||||
{
|
{
|
||||||
Ledger::pointer ledger = Ledger::getLastFullLedger();
|
Ledger::pointer ledger = Ledger::getLastFullLedger();
|
||||||
if (ledger)
|
if (ledger)
|
||||||
mMasterLedger.setLedgerRangePresent(0, ledger->getLedgerSeq());
|
mLedgerMaster.setLedgerRangePresent(0, ledger->getLedgerSeq());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -216,7 +216,7 @@ void Application::sweep()
|
|||||||
{
|
{
|
||||||
mMasterTransaction.sweep();
|
mMasterTransaction.sweep();
|
||||||
mHashedObjectStore.sweep();
|
mHashedObjectStore.sweep();
|
||||||
mMasterLedger.sweep();
|
mLedgerMaster.sweep();
|
||||||
mTempNodeCache.sweep();
|
mTempNodeCache.sweep();
|
||||||
mValidations.sweep();
|
mValidations.sweep();
|
||||||
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
|
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
|
||||||
@@ -249,12 +249,12 @@ void Application::startNewLedger()
|
|||||||
firstLedger->updateHash();
|
firstLedger->updateHash();
|
||||||
firstLedger->setClosed();
|
firstLedger->setClosed();
|
||||||
firstLedger->setAccepted();
|
firstLedger->setAccepted();
|
||||||
mMasterLedger.pushLedger(firstLedger);
|
mLedgerMaster.pushLedger(firstLedger);
|
||||||
|
|
||||||
Ledger::pointer secondLedger = boost::make_shared<Ledger>(true, boost::ref(*firstLedger));
|
Ledger::pointer secondLedger = boost::make_shared<Ledger>(true, boost::ref(*firstLedger));
|
||||||
secondLedger->setClosed();
|
secondLedger->setClosed();
|
||||||
secondLedger->setAccepted();
|
secondLedger->setAccepted();
|
||||||
mMasterLedger.pushLedger(secondLedger, boost::make_shared<Ledger>(true, boost::ref(*secondLedger)), false);
|
mLedgerMaster.pushLedger(secondLedger, boost::make_shared<Ledger>(true, boost::ref(*secondLedger)), false);
|
||||||
assert(!!secondLedger->getAccountState(rootAddress));
|
assert(!!secondLedger->getAccountState(rootAddress));
|
||||||
mNetOps.setLastCloseTime(secondLedger->getCloseTimeNC());
|
mNetOps.setLastCloseTime(secondLedger->getCloseTimeNC());
|
||||||
}
|
}
|
||||||
@@ -293,10 +293,10 @@ void Application::loadOldLedger()
|
|||||||
cLog(lsFATAL) << "Ledger is not sane.";
|
cLog(lsFATAL) << "Ledger is not sane.";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
mMasterLedger.setLedgerRangePresent(0, lastLedger->getLedgerSeq());
|
mLedgerMaster.setLedgerRangePresent(0, lastLedger->getLedgerSeq());
|
||||||
|
|
||||||
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);
|
mLedgerMaster.switchLedgers(lastLedger, openLedger);
|
||||||
mNetOps.setLastCloseTime(lastLedger->getCloseTimeNC());
|
mNetOps.setLastCloseTime(lastLedger->getCloseTimeNC());
|
||||||
}
|
}
|
||||||
catch (SHAMapMissingNode& mn)
|
catch (SHAMapMissingNode& mn)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Application
|
|||||||
|
|
||||||
Wallet mWallet;
|
Wallet mWallet;
|
||||||
UniqueNodeList mUNL;
|
UniqueNodeList mUNL;
|
||||||
LedgerMaster mMasterLedger;
|
LedgerMaster mLedgerMaster;
|
||||||
LedgerAcquireMaster mMasterLedgerAcquire;
|
LedgerAcquireMaster mMasterLedgerAcquire;
|
||||||
TransactionMaster mMasterTransaction;
|
TransactionMaster mMasterTransaction;
|
||||||
NetworkOPs mNetOps;
|
NetworkOPs mNetOps;
|
||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
boost::asio::io_service& getIOService() { return mIOService; }
|
boost::asio::io_service& getIOService() { return mIOService; }
|
||||||
boost::asio::io_service& getAuxService() { return mAuxService; }
|
boost::asio::io_service& getAuxService() { return mAuxService; }
|
||||||
|
|
||||||
LedgerMaster& getMasterLedger() { return mMasterLedger; }
|
LedgerMaster& getLedgerMaster() { return mLedgerMaster; }
|
||||||
LedgerAcquireMaster& getMasterLedgerAcquire() { return mMasterLedgerAcquire; }
|
LedgerAcquireMaster& getMasterLedgerAcquire() { return mMasterLedgerAcquire; }
|
||||||
TransactionMaster& getMasterTransaction() { return mMasterTransaction; }
|
TransactionMaster& getMasterTransaction() { return mMasterTransaction; }
|
||||||
NodeCache& getTempNodeCache() { return mTempNodeCache; }
|
NodeCache& getTempNodeCache() { return mTempNodeCache; }
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ const char* Job::toString(JobType t)
|
|||||||
case jtCLIENT: return "clientCommand";
|
case jtCLIENT: return "clientCommand";
|
||||||
case jtPEER: return "peerCommand";
|
case jtPEER: return "peerCommand";
|
||||||
case jtDISK: return "diskAccess";
|
case jtDISK: return "diskAccess";
|
||||||
case jtLEDGER: return "acceptLedger";
|
|
||||||
case jtRPC: return "rpc";
|
case jtRPC: return "rpc";
|
||||||
|
case jtACCEPTLEDGER: return "acceptLedger";
|
||||||
|
case jtPUBLEDGER: return "pubLedger";
|
||||||
default: assert(false); return "unknown";
|
default: assert(false); return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,11 @@ enum JobType
|
|||||||
jtCLIENT = 10,
|
jtCLIENT = 10,
|
||||||
jtPEER = 11,
|
jtPEER = 11,
|
||||||
jtDISK = 12,
|
jtDISK = 12,
|
||||||
jtLEDGER = 13,
|
jtRPC = 13,
|
||||||
jtRPC = 14,
|
jtACCEPTLEDGER = 14,
|
||||||
|
jtPUBLEDGER = 15,
|
||||||
};
|
};
|
||||||
#define NUM_JOB_TYPES 16
|
#define NUM_JOB_TYPES 24
|
||||||
|
|
||||||
class Job
|
class Job
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -438,7 +438,8 @@ void Ledger::saveAcceptedLedger(bool fromConsensus)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
theApp->getMasterLedger().setFullLedger(shared_from_this());
|
theApp->getLedgerMaster().setFullLedger(shared_from_this());
|
||||||
|
event = LoadEvent::pointer();
|
||||||
|
|
||||||
theApp->getOPs().pubLedger(shared_from_this());
|
theApp->getOPs().pubLedger(shared_from_this());
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ void LedgerAcquire::done()
|
|||||||
{
|
{
|
||||||
if (mAccept)
|
if (mAccept)
|
||||||
mLedger->setAccepted();
|
mLedger->setAccepted();
|
||||||
theApp->getMasterLedger().storeLedger(mLedger);
|
theApp->getLedgerMaster().storeLedger(mLedger);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < triggers.size(); ++i)
|
for (unsigned int i = 0; i < triggers.size(); ++i)
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
|
|||||||
|
|
||||||
if (mPreviousLedger->getHash() != mPrevLedgerHash)
|
if (mPreviousLedger->getHash() != mPrevLedgerHash)
|
||||||
{ // we need to switch the ledger we're working from
|
{ // we need to switch the ledger we're working from
|
||||||
Ledger::pointer newLCL = theApp->getMasterLedger().getLedgerByHash(lclHash);
|
Ledger::pointer newLCL = theApp->getLedgerMaster().getLedgerByHash(lclHash);
|
||||||
if (newLCL)
|
if (newLCL)
|
||||||
mPreviousLedger = newLCL;
|
mPreviousLedger = newLCL;
|
||||||
else if (!mAcquiringLedger || (mAcquiringLedger->getHash() != mPrevLedgerHash))
|
else if (!mAcquiringLedger || (mAcquiringLedger->getHash() != mPrevLedgerHash))
|
||||||
@@ -578,7 +578,7 @@ int LedgerConsensus::startup()
|
|||||||
|
|
||||||
void LedgerConsensus::statePreClose()
|
void LedgerConsensus::statePreClose()
|
||||||
{ // it is shortly before ledger close time
|
{ // it is shortly before ledger close time
|
||||||
bool anyTransactions = theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap()->getHash().isNonZero();
|
bool anyTransactions = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap()->getHash().isNonZero();
|
||||||
int proposersClosed = mPeerPositions.size();
|
int proposersClosed = mPeerPositions.size();
|
||||||
|
|
||||||
// This ledger is open. This computes how long since the last ledger closed
|
// This ledger is open. This computes how long since the last ledger closed
|
||||||
@@ -613,7 +613,7 @@ void LedgerConsensus::closeLedger()
|
|||||||
mCloseTime = theApp->getOPs().getCloseTimeNC();
|
mCloseTime = theApp->getOPs().getCloseTimeNC();
|
||||||
theApp->getOPs().setLastCloseTime(mCloseTime);
|
theApp->getOPs().setLastCloseTime(mCloseTime);
|
||||||
statusChange(ripple::neCLOSING_LEDGER, *mPreviousLedger);
|
statusChange(ripple::neCLOSING_LEDGER, *mPreviousLedger);
|
||||||
takeInitialPosition(*theApp->getMasterLedger().closeLedger(true));
|
takeInitialPosition(*theApp->getLedgerMaster().closeLedger(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedgerConsensus::stateEstablish()
|
void LedgerConsensus::stateEstablish()
|
||||||
@@ -813,7 +813,7 @@ SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool do
|
|||||||
|
|
||||||
if (mState == lcsPRE_CLOSE)
|
if (mState == lcsPRE_CLOSE)
|
||||||
{
|
{
|
||||||
SHAMap::pointer currentMap = theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap();
|
SHAMap::pointer currentMap = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap();
|
||||||
if (currentMap->getHash() == hash)
|
if (currentMap->getHash() == hash)
|
||||||
{
|
{
|
||||||
cLog(lsINFO) << "node proposes our open transaction set";
|
cLog(lsINFO) << "node proposes our open transaction set";
|
||||||
@@ -1027,7 +1027,7 @@ void LedgerConsensus::beginAccept(bool synchronous)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet,
|
theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet,
|
||||||
theApp->getJobQueue().getLoadEvent(jtLEDGER)));
|
theApp->getJobQueue().getLoadEvent(jtACCEPTLEDGER)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1251,7 +1251,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
|||||||
cLog(lsINFO) << "CNF newLCL " << newLCLHash;
|
cLog(lsINFO) << "CNF newLCL " << newLCLHash;
|
||||||
|
|
||||||
Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL));
|
Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL));
|
||||||
ScopedLock sl = theApp->getMasterLedger().getLock();
|
ScopedLock sl = theApp->getLedgerMaster().getLock();
|
||||||
|
|
||||||
// Apply disputed transactions that didn't get in
|
// Apply disputed transactions that didn't get in
|
||||||
TransactionEngine engine(newOL);
|
TransactionEngine engine(newOL);
|
||||||
@@ -1274,9 +1274,9 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cLog(lsINFO) << "Applying transactions from current ledger";
|
cLog(lsINFO) << "Applying transactions from current ledger";
|
||||||
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
|
applyTransactions(theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
|
||||||
failedTransactions, true);
|
failedTransactions, true);
|
||||||
theApp->getMasterLedger().pushLedger(newLCL, newOL, !mConsensusFail);
|
theApp->getLedgerMaster().pushLedger(newLCL, newOL, !mConsensusFail);
|
||||||
mNewLedgerHash = newLCL->getHash();
|
mNewLedgerHash = newLCL->getHash();
|
||||||
mState = lcsACCEPTED;
|
mState = lcsACCEPTED;
|
||||||
sl.unlock();
|
sl.unlock();
|
||||||
|
|||||||
@@ -946,7 +946,7 @@ Json::Value NetworkOPs::getServerInfo()
|
|||||||
if (mNeedNetworkLedger)
|
if (mNeedNetworkLedger)
|
||||||
info["networkLedger"] = "waiting";
|
info["networkLedger"] = "waiting";
|
||||||
|
|
||||||
info["completeLedgers"] = theApp->getMasterLedger().getCompleteLedgers();
|
info["completeLedgers"] = theApp->getLedgerMaster().getCompleteLedgers();
|
||||||
info["peers"] = theApp->getConnectionPool().getPeerCount();
|
info["peers"] = theApp->getConnectionPool().getPeerCount();
|
||||||
|
|
||||||
Json::Value lastClose = Json::objectValue;
|
Json::Value lastClose = Json::objectValue;
|
||||||
@@ -985,7 +985,7 @@ void NetworkOPs::pubProposedTransaction(Ledger::ref lpCurrent, const SerializedT
|
|||||||
Json::Value jvObj = transJson(stTxn, terResult, false, lpCurrent, "transaction");
|
Json::Value jvObj = transJson(stTxn, terResult, false, lpCurrent, "transaction");
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
|
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
|
||||||
{
|
{
|
||||||
ispListener->send(jvObj);
|
ispListener->send(jvObj);
|
||||||
@@ -1002,8 +1002,10 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
|
|||||||
if (NetworkOPs::omDISCONNECTED == getOperatingMode())
|
if (NetworkOPs::omDISCONNECTED == getOperatingMode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtPUBLEDGER);
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
|
|
||||||
if (!mSubLedger.empty())
|
if (!mSubLedger.empty())
|
||||||
{
|
{
|
||||||
@@ -1076,7 +1078,7 @@ void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedT
|
|||||||
Json::Value jvObj = transJson(stTxn, terResult, true, lpCurrent, "transaction");
|
Json::Value jvObj = transJson(stTxn, terResult, true, lpCurrent, "transaction");
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
BOOST_FOREACH(InfoSub* ispListener, mSubTransactions)
|
BOOST_FOREACH(InfoSub* ispListener, mSubTransactions)
|
||||||
{
|
{
|
||||||
ispListener->send(jvObj);
|
ispListener->send(jvObj);
|
||||||
@@ -1097,7 +1099,7 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr
|
|||||||
boost::unordered_set<InfoSub*> notify;
|
boost::unordered_set<InfoSub*> notify;
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
|
|
||||||
if(!bAccepted && mSubRTAccount.empty()) return;
|
if(!bAccepted && mSubRTAccount.empty()) return;
|
||||||
|
|
||||||
@@ -1183,7 +1185,7 @@ void NetworkOPs::subAccount(InfoSub* ispListener, const boost::unordered_set<Rip
|
|||||||
subInfoMapType& subMap=mSubAccount;
|
subInfoMapType& subMap=mSubAccount;
|
||||||
if(rt) subMap=mSubRTAccount;
|
if(rt) subMap=mSubRTAccount;
|
||||||
|
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
|
|
||||||
BOOST_FOREACH(const RippleAddress& naAccountID, vnaAccountIDs)
|
BOOST_FOREACH(const RippleAddress& naAccountID, vnaAccountIDs)
|
||||||
{
|
{
|
||||||
@@ -1208,7 +1210,7 @@ void NetworkOPs::unsubAccount(InfoSub* ispListener, const boost::unordered_set<R
|
|||||||
{
|
{
|
||||||
subInfoMapType& subMap= rt ? mSubRTAccount : mSubAccount;
|
subInfoMapType& subMap= rt ? mSubRTAccount : mSubAccount;
|
||||||
|
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||||
|
|
||||||
BOOST_FOREACH(const RippleAddress& naAccountID, vnaAccountIDs)
|
BOOST_FOREACH(const RippleAddress& naAccountID, vnaAccountIDs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#ifndef __NETWORK_OPS__
|
#ifndef __NETWORK_OPS__
|
||||||
#define __NETWORK_OPS__
|
#define __NETWORK_OPS__
|
||||||
|
|
||||||
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
#include <boost/interprocess/sync/sharable_lock.hpp>
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
// XXX Split into more locks.
|
// XXX Split into more locks.
|
||||||
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
|
boost::recursive_mutex mMonitorLock;
|
||||||
subInfoMapType mSubAccount;
|
subInfoMapType mSubAccount;
|
||||||
subInfoMapType mSubRTAccount;
|
subInfoMapType mSubRTAccount;
|
||||||
subSubmitMapType mSubmitMap; // TODO: probably dump this
|
subSubmitMapType mSubmitMap; // TODO: probably dump this
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ PathOption::PathOption(PathOption::pointer other)
|
|||||||
// functionality is left to the future.
|
// functionality is left to the future.
|
||||||
//
|
//
|
||||||
Pathfinder::Pathfinder(const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount)
|
Pathfinder::Pathfinder(const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount)
|
||||||
: mSrcAccountID(srcAccountID.getAccountID()), mDstAccountID(dstAccountID.getAccountID()), mDstAmount(dstAmount), mSrcCurrencyID(srcCurrencyID), mSrcIssuerID(srcIssuerID), mOrderBook(theApp->getMasterLedger().getCurrentLedger())
|
: mSrcAccountID(srcAccountID.getAccountID()), mDstAccountID(dstAccountID.getAccountID()), mDstAmount(dstAmount), mSrcCurrencyID(srcCurrencyID), mSrcIssuerID(srcIssuerID), mOrderBook(theApp->getLedgerMaster().getCurrentLedger())
|
||||||
{
|
{
|
||||||
mLedger=theApp->getMasterLedger().getCurrentLedger();
|
mLedger=theApp->getLedgerMaster().getCurrentLedger();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If possible, returns a single path.
|
// If possible, returns a single path.
|
||||||
|
|||||||
@@ -1237,7 +1237,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(ledgerhash.begin(), packet.ledgerhash().data(), 32);
|
memcpy(ledgerhash.begin(), packet.ledgerhash().data(), 32);
|
||||||
ledger = theApp->getMasterLedger().getLedgerByHash(ledgerhash);
|
ledger = theApp->getLedgerMaster().getLedgerByHash(ledgerhash);
|
||||||
|
|
||||||
tLog(!ledger, lsINFO) << "Don't have ledger " << ledgerhash;
|
tLog(!ledger, lsINFO) << "Don't have ledger " << ledgerhash;
|
||||||
if (!ledger && (packet.has_querytype() && !packet.has_requestcookie()))
|
if (!ledger && (packet.has_querytype() && !packet.has_requestcookie()))
|
||||||
@@ -1264,16 +1264,16 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet)
|
|||||||
}
|
}
|
||||||
else if (packet.has_ledgerseq())
|
else if (packet.has_ledgerseq())
|
||||||
{
|
{
|
||||||
ledger = theApp->getMasterLedger().getLedgerBySeq(packet.ledgerseq());
|
ledger = theApp->getLedgerMaster().getLedgerBySeq(packet.ledgerseq());
|
||||||
tLog(!ledger, lsINFO) << "Don't have ledger " << packet.ledgerseq();
|
tLog(!ledger, lsINFO) << "Don't have ledger " << packet.ledgerseq();
|
||||||
}
|
}
|
||||||
else if (packet.has_ltype() && (packet.ltype() == ripple::ltCURRENT))
|
else if (packet.has_ltype() && (packet.ltype() == ripple::ltCURRENT))
|
||||||
ledger = theApp->getMasterLedger().getCurrentLedger();
|
ledger = theApp->getLedgerMaster().getCurrentLedger();
|
||||||
else if (packet.has_ltype() && (packet.ltype() == ripple::ltCLOSED) )
|
else if (packet.has_ltype() && (packet.ltype() == ripple::ltCLOSED) )
|
||||||
{
|
{
|
||||||
ledger = theApp->getMasterLedger().getClosedLedger();
|
ledger = theApp->getLedgerMaster().getClosedLedger();
|
||||||
if (ledger && !ledger->isClosed())
|
if (ledger && !ledger->isClosed())
|
||||||
ledger = theApp->getMasterLedger().getLedgerBySeq(ledger->getLedgerSeq() - 1);
|
ledger = theApp->getLedgerMaster().getLedgerBySeq(ledger->getLedgerSeq() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1529,7 +1529,7 @@ void Peer::sendHello()
|
|||||||
h.set_ipv4port(theConfig.PEER_PORT);
|
h.set_ipv4port(theConfig.PEER_PORT);
|
||||||
h.set_nodeprivate(theConfig.PEER_PRIVATE);
|
h.set_nodeprivate(theConfig.PEER_PRIVATE);
|
||||||
|
|
||||||
Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger();
|
Ledger::pointer closedLedger = theApp->getLedgerMaster().getClosedLedger();
|
||||||
if (closedLedger && closedLedger->isClosed())
|
if (closedLedger && closedLedger->isClosed())
|
||||||
{
|
{
|
||||||
uint256 hash = closedLedger->getHash();
|
uint256 hash = closedLedger->getHash();
|
||||||
|
|||||||
@@ -1225,8 +1225,8 @@ Json::Value RPCHandler::doLedger(const Json::Value& params)
|
|||||||
if (getParamCount(params) == 0)
|
if (getParamCount(params) == 0)
|
||||||
{
|
{
|
||||||
Json::Value ret(Json::objectValue), current(Json::objectValue), closed(Json::objectValue);
|
Json::Value ret(Json::objectValue), current(Json::objectValue), closed(Json::objectValue);
|
||||||
theApp->getMasterLedger().getCurrentLedger()->addJson(current, 0);
|
theApp->getLedgerMaster().getCurrentLedger()->addJson(current, 0);
|
||||||
theApp->getMasterLedger().getClosedLedger()->addJson(closed, 0);
|
theApp->getLedgerMaster().getClosedLedger()->addJson(closed, 0);
|
||||||
ret["open"] = current;
|
ret["open"] = current;
|
||||||
ret["closed"] = closed;
|
ret["closed"] = closed;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1240,13 +1240,13 @@ Json::Value RPCHandler::doLedger(const Json::Value& params)
|
|||||||
|
|
||||||
Ledger::pointer ledger;
|
Ledger::pointer ledger;
|
||||||
if (param == "current")
|
if (param == "current")
|
||||||
ledger = theApp->getMasterLedger().getCurrentLedger();
|
ledger = theApp->getLedgerMaster().getCurrentLedger();
|
||||||
else if ((param == "lastclosed") || (param == "lastaccepted"))
|
else if ((param == "lastclosed") || (param == "lastaccepted"))
|
||||||
ledger = theApp->getMasterLedger().getClosedLedger();
|
ledger = theApp->getLedgerMaster().getClosedLedger();
|
||||||
else if (param.size() > 12)
|
else if (param.size() > 12)
|
||||||
ledger = theApp->getMasterLedger().getLedgerByHash(uint256(param));
|
ledger = theApp->getLedgerMaster().getLedgerByHash(uint256(param));
|
||||||
else
|
else
|
||||||
ledger = theApp->getMasterLedger().getLedgerBySeq(lexical_cast_s<uint32>(param));
|
ledger = theApp->getLedgerMaster().getLedgerBySeq(lexical_cast_s<uint32>(param));
|
||||||
|
|
||||||
if (!ledger)
|
if (!ledger)
|
||||||
return rpcError(rpcLGR_NOT_FOUND);
|
return rpcError(rpcLGR_NOT_FOUND);
|
||||||
@@ -1308,7 +1308,7 @@ Json::Value RPCHandler::doAccountTransactions(const Json::Value& params)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
txn->setLedger(it->first);
|
txn->setLedger(it->first);
|
||||||
ret["transactions"].append(txn->getJson(0));
|
ret["transactions"].append(txn->getJson(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1854,7 +1854,7 @@ Json::Value RPCHandler::doTransactionEntry(const Json::Value& jvRequest)
|
|||||||
// XXX Relying on trusted WSS client. Would be better to have a strict routine, returning success or failure.
|
// XXX Relying on trusted WSS client. Would be better to have a strict routine, returning success or failure.
|
||||||
uLedgerID.SetHex(jvRequest["ledger_hash"].asString());
|
uLedgerID.SetHex(jvRequest["ledger_hash"].asString());
|
||||||
|
|
||||||
Ledger::pointer lpLedger = theApp->getMasterLedger().getLedgerByHash(uLedgerID);
|
Ledger::pointer lpLedger = theApp->getLedgerMaster().getLedgerByHash(uLedgerID);
|
||||||
|
|
||||||
if (!lpLedger) {
|
if (!lpLedger) {
|
||||||
jvResult["error"] = "ledgerNotFound";
|
jvResult["error"] = "ledgerNotFound";
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void RippleLines::printRippleLines()
|
|||||||
|
|
||||||
RippleLines::RippleLines(const uint160& accountID )
|
RippleLines::RippleLines(const uint160& accountID )
|
||||||
{
|
{
|
||||||
fillLines(accountID,theApp->getMasterLedger().getCurrentLedger());
|
fillLines(accountID,theApp->getLedgerMaster().getCurrentLedger());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleLines::fillLines(const uint160& accountID, Ledger::ref ledger)
|
void RippleLines::fillLines(const uint160& accountID, Ledger::ref ledger)
|
||||||
|
|||||||
@@ -306,11 +306,25 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// options 1 to include the date of the transaction
|
||||||
Json::Value Transaction::getJson(int options) const
|
Json::Value Transaction::getJson(int options) const
|
||||||
{
|
{
|
||||||
|
|
||||||
Json::Value ret(mTransaction->getJson(0));
|
Json::Value ret(mTransaction->getJson(0));
|
||||||
|
|
||||||
if (mInLedger) ret["inLedger"]=mInLedger;
|
if (mInLedger)
|
||||||
|
{
|
||||||
|
ret["inLedger"]=mInLedger;
|
||||||
|
|
||||||
|
if(options==1)
|
||||||
|
{
|
||||||
|
Ledger::pointer ledger=theApp->getLedgerMaster().getLedgerBySeq(mInLedger);
|
||||||
|
if(ledger)
|
||||||
|
{
|
||||||
|
ret["date"]=ledger->getCloseTimeNC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (mStatus)
|
switch (mStatus)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ Request.prototype.ripple_state = function (account, issuer, currency) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
Request.prototype.accounts = function (accounts) {
|
Request.prototype.accounts = function (accounts, realtime) {
|
||||||
if ("object" !== typeof accounts) {
|
if ("object" !== typeof accounts) {
|
||||||
accounts = [accounts];
|
accounts = [accounts];
|
||||||
}
|
}
|
||||||
@@ -158,11 +158,19 @@ Request.prototype.accounts = function (accounts) {
|
|||||||
for (var i = 0, l = accounts.length; i < l; i++) {
|
for (var i = 0, l = accounts.length; i < l; i++) {
|
||||||
procAccounts.push(UInt160.json_rewrite(accounts[i]));
|
procAccounts.push(UInt160.json_rewrite(accounts[i]));
|
||||||
}
|
}
|
||||||
this.message.accounts = procAccounts;
|
if (realtime) {
|
||||||
|
this.message.rt_accounts = procAccounts;
|
||||||
|
} else {
|
||||||
|
this.message.accounts = procAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Request.prototype.rt_accounts = function (accounts) {
|
||||||
|
return this.accounts(accounts, true);
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Remote - access to a remote Ripple server via websocket.
|
// Remote - access to a remote Ripple server via websocket.
|
||||||
//
|
//
|
||||||
@@ -181,6 +189,7 @@ var Remote = function (opts, trace) {
|
|||||||
this.trusted = opts.trusted;
|
this.trusted = opts.trusted;
|
||||||
this.websocket_ip = opts.websocket_ip;
|
this.websocket_ip = opts.websocket_ip;
|
||||||
this.websocket_port = opts.websocket_port;
|
this.websocket_port = opts.websocket_port;
|
||||||
|
this.local_sequence = opts.local_sequence;
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.trace = opts.trace || trace;
|
this.trace = opts.trace || trace;
|
||||||
this._ledger_current_index = undefined;
|
this._ledger_current_index = undefined;
|
||||||
@@ -479,7 +488,12 @@ Remote.prototype._connect_message = function (ws, json) {
|
|||||||
|
|
||||||
this.emit('ledger_closed', message.ledger_hash, message.ledger_index);
|
this.emit('ledger_closed', message.ledger_hash, message.ledger_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Account subscription event
|
||||||
|
case 'account':
|
||||||
|
if (this.trace) console.log("remote: account: %s", JSON.stringify(message, undefined, 2));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unexpected = true;
|
unexpected = true;
|
||||||
break;
|
break;
|
||||||
@@ -547,7 +561,7 @@ Remote.prototype.request_ledger = function (params) {
|
|||||||
|
|
||||||
// Only for unit testing.
|
// Only for unit testing.
|
||||||
Remote.prototype.request_ledger_hash = function () {
|
Remote.prototype.request_ledger_hash = function () {
|
||||||
assert(this.trusted); // If not trusted, need to check proof.
|
//assert(this.trusted); // If not trusted, need to check proof.
|
||||||
|
|
||||||
return new Request(this, 'ledger_closed');
|
return new Request(this, 'ledger_closed');
|
||||||
};
|
};
|
||||||
@@ -569,7 +583,7 @@ Remote.prototype.request_ledger_current = function () {
|
|||||||
// .ledger_index()
|
// .ledger_index()
|
||||||
// .offer_id()
|
// .offer_id()
|
||||||
Remote.prototype.request_ledger_entry = function (type) {
|
Remote.prototype.request_ledger_entry = function (type) {
|
||||||
assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
|
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var request = new Request(this, 'ledger_entry');
|
var request = new Request(this, 'ledger_entry');
|
||||||
@@ -652,7 +666,7 @@ Remote.prototype.request_unsubscribe = function (streams) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Remote.prototype.request_transaction_entry = function (hash) {
|
Remote.prototype.request_transaction_entry = function (hash) {
|
||||||
assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
|
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
|
||||||
|
|
||||||
return (new Request(this, 'transaction_entry'))
|
return (new Request(this, 'transaction_entry'))
|
||||||
.tx_hash(hash);
|
.tx_hash(hash);
|
||||||
@@ -706,12 +720,12 @@ Remote.prototype.submit = function (transaction) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!transaction.tx_json.Sequence) {
|
if (self.local_sequence && !transaction.tx_json.Sequence) {
|
||||||
transaction.tx_json.Sequence = this.account_seq(transaction.tx_json.Account, 'ADVANCE');
|
transaction.tx_json.Sequence = this.account_seq(transaction.tx_json.Account, 'ADVANCE');
|
||||||
// console.log("Sequence: %s", transaction.tx_json.Sequence);
|
// console.log("Sequence: %s", transaction.tx_json.Sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transaction.tx_json.Sequence) {
|
if (self.local_sequence && !transaction.tx_json.Sequence) {
|
||||||
// Look in the last closed ledger.
|
// Look in the last closed ledger.
|
||||||
this.account_seq_cache(transaction.tx_json.Account, false)
|
this.account_seq_cache(transaction.tx_json.Account, false)
|
||||||
.on('success_account_seq_cache', function () {
|
.on('success_account_seq_cache', function () {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ exports.servers = {
|
|||||||
'rpc_port' : 5005,
|
'rpc_port' : 5005,
|
||||||
'websocket_ip' : "127.0.0.1",
|
'websocket_ip' : "127.0.0.1",
|
||||||
'websocket_port' : 5006,
|
'websocket_port' : 5006,
|
||||||
|
'local_sequence' : true,
|
||||||
// 'validation_seed' : "shhDFVsmS2GSu5vUyZSPXYfj1r79h",
|
// 'validation_seed' : "shhDFVsmS2GSu5vUyZSPXYfj1r79h",
|
||||||
// 'validators' : "n9L8LZZCwsdXzKUN9zoVxs4YznYXZ9hEhsQZY7aVpxtFaSceiyDZ beta"
|
// 'validators' : "n9L8LZZCwsdXzKUN9zoVxs4YznYXZ9hEhsQZY7aVpxtFaSceiyDZ beta"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ var webpack = require("webpack");
|
|||||||
var async = require("async");
|
var async = require("async");
|
||||||
var extend = require("extend");
|
var extend = require("extend");
|
||||||
|
|
||||||
var programPath = __dirname + "/src/js/remote.js";
|
|
||||||
|
|
||||||
var cfg = {
|
var cfg = {
|
||||||
|
// General settings
|
||||||
|
baseName: pkg.name,
|
||||||
|
programPath: __dirname + "/src/js/remote.js",
|
||||||
|
|
||||||
|
// CLI-configurable options
|
||||||
watch: false,
|
watch: false,
|
||||||
outputDir: __dirname + "/build"
|
outputDir: __dirname + "/build"
|
||||||
};
|
};
|
||||||
@@ -41,7 +44,7 @@ function build(opts) {
|
|||||||
opts.output = cfg.outputDir + "/"+opts.filename;
|
opts.output = cfg.outputDir + "/"+opts.filename;
|
||||||
return function (callback) {
|
return function (callback) {
|
||||||
var filename = opts.filename;
|
var filename = opts.filename;
|
||||||
webpack(programPath, opts, function (err, result) {
|
webpack(cfg.programPath, opts, function (err, result) {
|
||||||
console.log(' '+filename, result.hash, '['+result.modulesCount+']');
|
console.log(' '+filename, result.hash, '['+result.modulesCount+']');
|
||||||
if ("function" === typeof callback) {
|
if ("function" === typeof callback) {
|
||||||
callback(err);
|
callback(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user