mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
WS: Fixes for ledger_hash.
This commit is contained in:
@@ -917,12 +917,12 @@ Json::Value NetworkOPs::pubBootstrapAccountInfo(Ledger::ref lpAccepted, const Ri
|
||||
{
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
jvObj["type"] = "accountInfoBootstrap";
|
||||
jvObj["account"] = naAccountID.humanAccountID();
|
||||
jvObj["owner"] = getOwnerInfo(lpAccepted, naAccountID);
|
||||
jvObj["ledger_closed_index"] = lpAccepted->getLedgerSeq();
|
||||
jvObj["ledger_closed"] = lpAccepted->getHash().ToString();
|
||||
jvObj["ledger_closed_time"] = Json::Value::UInt(utFromSeconds(lpAccepted->getCloseTimeNC()));
|
||||
jvObj["type"] = "accountInfoBootstrap";
|
||||
jvObj["account"] = naAccountID.humanAccountID();
|
||||
jvObj["owner"] = getOwnerInfo(lpAccepted, naAccountID);
|
||||
jvObj["ledger_index"] = lpAccepted->getLedgerSeq();
|
||||
jvObj["ledger_hash"] = lpAccepted->getHash().ToString();
|
||||
jvObj["ledger_time"] = Json::Value::UInt(utFromSeconds(lpAccepted->getCloseTimeNC()));
|
||||
|
||||
return jvObj;
|
||||
}
|
||||
@@ -930,7 +930,7 @@ Json::Value NetworkOPs::pubBootstrapAccountInfo(Ledger::ref lpAccepted, const Ri
|
||||
void NetworkOPs::pubProposedTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult)
|
||||
{
|
||||
Json::Value jvObj = transJson(stTxn, terResult, false, lpCurrent, "transaction");
|
||||
|
||||
|
||||
{
|
||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
|
||||
@@ -956,10 +956,10 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
|
||||
{
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
jvObj["type"] = "ledgerClosed";
|
||||
jvObj["ledger_closed_index"] = lpAccepted->getLedgerSeq();
|
||||
jvObj["ledger_closed"] = lpAccepted->getHash().ToString();
|
||||
jvObj["ledger_closed_time"] = Json::Value::UInt(utFromSeconds(lpAccepted->getCloseTimeNC()));
|
||||
jvObj["type"] = "ledgerClosed";
|
||||
jvObj["ledger_index"] = lpAccepted->getLedgerSeq();
|
||||
jvObj["ledger_hash"] = lpAccepted->getHash().ToString();
|
||||
jvObj["ledger_time"] = Json::Value::UInt(utFromSeconds(lpAccepted->getCloseTimeNC()));
|
||||
|
||||
BOOST_FOREACH(InfoSub* ispListener, mSubLedger)
|
||||
{
|
||||
@@ -986,8 +986,6 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
|
||||
// TODO: remove old entries from the submit map
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terResult, bool bAccepted, Ledger::ref lpCurrent, const std::string& strType)
|
||||
@@ -1001,8 +999,8 @@ Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terRes
|
||||
jvObj["type"] = strType;
|
||||
jvObj["transaction"] = stTxn.getJson(0);
|
||||
if (bAccepted) {
|
||||
jvObj["ledger_closed_index"] = lpCurrent->getLedgerSeq();
|
||||
jvObj["ledger_closed"] = lpCurrent->getHash().ToString();
|
||||
jvObj["ledger_index"] = lpCurrent->getLedgerSeq();
|
||||
jvObj["ledger_hash"] = lpCurrent->getHash().ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1032,7 +1030,7 @@ void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedT
|
||||
ispListener->send(jvObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pubAccountTransaction(lpCurrent,stTxn,terResult,true);
|
||||
}
|
||||
|
||||
@@ -1181,8 +1179,12 @@ void NetworkOPs::unsubAccountChanges(InfoSub* ispListener)
|
||||
#endif
|
||||
|
||||
// <-- bool: true=added, false=already there
|
||||
bool NetworkOPs::subLedger(InfoSub* ispListener)
|
||||
bool NetworkOPs::subLedger(InfoSub* ispListener, Json::Value& jvResult)
|
||||
{
|
||||
jvResult["ledger_index"] = getClosedLedger()->getLedgerSeq();
|
||||
jvResult["ledger_hash"] = getClosedLedger()->getHash().ToString();
|
||||
jvResult["ledger_time"] = Json::Value::UInt(utFromSeconds(getClosedLedger()->getCloseTimeNC()));
|
||||
|
||||
return mSubLedger.insert(ispListener).second;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ protected:
|
||||
|
||||
// XXX Split into more locks.
|
||||
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
|
||||
subInfoMapType mSubAccount;
|
||||
subInfoMapType mSubRTAccount;
|
||||
subInfoMapType mSubAccount;
|
||||
subInfoMapType mSubRTAccount;
|
||||
subSubmitMapType mSubmitMap;
|
||||
|
||||
boost::unordered_set<InfoSub*> mSubLedger; // accepted ledgers
|
||||
@@ -111,11 +111,12 @@ public:
|
||||
return mMode >= omTRACKING;
|
||||
}
|
||||
|
||||
Ledger::pointer getClosedLedger() { return mLedgerMaster->getClosedLedger(); }
|
||||
Ledger::pointer getCurrentLedger() { return mLedgerMaster->getCurrentLedger(); }
|
||||
Ledger::pointer getLedgerByHash(const uint256& hash) { return mLedgerMaster->getLedgerByHash(hash); }
|
||||
Ledger::pointer getLedgerBySeq(const uint32 seq) { return mLedgerMaster->getLedgerBySeq(seq); }
|
||||
|
||||
uint256 getClosedLedger()
|
||||
uint256 getClosedLedgerHash()
|
||||
{ return mLedgerMaster->getClosedLedger()->getHash(); }
|
||||
|
||||
SLE::pointer getSLE(Ledger::pointer lpLedger, const uint256& uHash) { return lpLedger->getSLE(uHash); }
|
||||
@@ -224,7 +225,7 @@ public:
|
||||
void subAccount(InfoSub* ispListener, const boost::unordered_set<RippleAddress>& vnaAccountIDs,bool rt);
|
||||
void unsubAccount(InfoSub* ispListener, const boost::unordered_set<RippleAddress>& vnaAccountIDs,bool rt);
|
||||
|
||||
bool subLedger(InfoSub* ispListener);
|
||||
bool subLedger(InfoSub* ispListener, Json::Value& jvResult);
|
||||
bool unsubLedger(InfoSub* ispListener);
|
||||
|
||||
bool subServer(InfoSub* ispListener);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <openssl/md5.h>
|
||||
/*
|
||||
carries out the RPC
|
||||
carries out the RPC
|
||||
|
||||
*/
|
||||
|
||||
@@ -341,7 +341,7 @@ Json::Value RPCHandler::doAccountInfo(const Json::Value ¶ms)
|
||||
|
||||
// Get info on account.
|
||||
|
||||
uint256 uAccepted = mNetOps->getClosedLedger();
|
||||
uint256 uAccepted = mNetOps->getClosedLedgerHash();
|
||||
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
|
||||
|
||||
if (jAccepted.empty())
|
||||
@@ -507,7 +507,7 @@ Json::Value RPCHandler::doOwnerInfo(const Json::Value& params)
|
||||
|
||||
// Get info on account.
|
||||
|
||||
uint256 uAccepted = mNetOps->getClosedLedger();
|
||||
uint256 uAccepted = mNetOps->getClosedLedgerHash();
|
||||
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
|
||||
|
||||
ret["accepted"] = jAccepted.empty() ? mNetOps->getOwnerInfo(uAccepted, naAccount) : jAccepted;
|
||||
@@ -621,7 +621,7 @@ Json::Value RPCHandler::doProfile(const Json::Value ¶ms)
|
||||
// ripple_lines_get <account>|<nickname>|<account_public_key> [<index>]
|
||||
Json::Value RPCHandler::doRippleLinesGet(const Json::Value ¶ms)
|
||||
{
|
||||
// uint256 uAccepted = mNetOps->getClosedLedger();
|
||||
// uint256 uAccepted = mNetOps->getClosedLedgerHash();
|
||||
|
||||
std::string strIdent = params[0u].asString();
|
||||
bool bIndex;
|
||||
@@ -1020,11 +1020,11 @@ Json::Value RPCHandler::doTx(const Json::Value& params)
|
||||
Json::Value RPCHandler::doLedgerClosed(const Json::Value& params)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
uint256 uLedger = mNetOps->getClosedLedger();
|
||||
uint256 uLedger = mNetOps->getClosedLedgerHash();
|
||||
|
||||
jvResult["ledger_closed_index"] = mNetOps->getLedgerID(uLedger);
|
||||
jvResult["ledger_closed"] = uLedger.ToString();
|
||||
//jvResult["ledger_closed_time"] = uLedger.
|
||||
jvResult["ledger_index"] = mNetOps->getLedgerID(uLedger);
|
||||
jvResult["ledger_hash"] = uLedger.ToString();
|
||||
//jvResult["ledger_time"] = uLedger.
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -1373,7 +1373,7 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
{
|
||||
return rpcError(rpcNO_CURRENT);
|
||||
}
|
||||
else if ((commandsA[i].iOptions & optClosed) && mNetOps->getClosedLedger().isZero())
|
||||
else if ((commandsA[i].iOptions & optClosed) && !mNetOps->getClosedLedger())
|
||||
{
|
||||
return rpcError(rpcNO_CLOSED);
|
||||
}
|
||||
@@ -1680,7 +1680,7 @@ Json::Value RPCHandler::doLedgerEntry(const Json::Value& params)
|
||||
if(!reader.parse(params[0u].asString(),jvRequest))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
uint256 uLedger = jvRequest.isMember("ledger_closed") ? uint256(jvRequest["ledger_closed"].asString()) : 0;
|
||||
uint256 uLedger = jvRequest.isMember("ledger_hash") ? uint256(jvRequest["ledger_hash"].asString()) : 0;
|
||||
uint32 uLedgerIndex = jvRequest.isMember("ledger_index") && jvRequest["ledger_index"].isNumeric() ? jvRequest["ledger_index"].asUInt() : 0;
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
@@ -1718,9 +1718,9 @@ Json::Value RPCHandler::doLedgerEntry(const Json::Value& params)
|
||||
if (lpLedger->isClosed())
|
||||
{
|
||||
if (!!uLedger)
|
||||
jvResult["ledger_closed"] = uLedger.ToString();
|
||||
jvResult["ledger_hash"] = uLedger.ToString();
|
||||
|
||||
jvResult["ledger_closed_index"] = uLedgerIndex;
|
||||
jvResult["ledger_index"] = uLedgerIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user