mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Work on WS account_info_subscribe.
This commit is contained in:
@@ -220,10 +220,14 @@ NicknameState::pointer NetworkOPs::getNicknameState(const uint256& uLedger, cons
|
||||
//
|
||||
|
||||
Json::Value NetworkOPs::getOwnerInfo(const uint256& uLedger, const NewcoinAddress& naAccount)
|
||||
{
|
||||
return getOwnerInfo(mLedgerMaster->getLedgerByHash(uLedger), naAccount);
|
||||
}
|
||||
|
||||
Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddress& naAccount)
|
||||
{
|
||||
Json::Value jvObjects(Json::arrayValue);
|
||||
|
||||
Ledger::pointer lpLedger = mLedgerMaster->getLedgerByHash(uLedger);
|
||||
uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID());
|
||||
|
||||
LedgerStateParms lspNode = lepNONE;
|
||||
@@ -236,9 +240,9 @@ Json::Value NetworkOPs::getOwnerInfo(const uint256& uLedger, const NewcoinAddres
|
||||
do
|
||||
{
|
||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
const std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
|
||||
BOOST_FOREACH(uint256& uDirEntry, vuiIndexes)
|
||||
BOOST_FOREACH(const uint256& uDirEntry, vuiIndexes)
|
||||
{
|
||||
LedgerStateParms lspOffer = lepNONE;
|
||||
SLE::pointer sleOffer = lpLedger->getOffer(lspOffer, uDirEntry);
|
||||
@@ -728,9 +732,23 @@ Json::Value NetworkOPs::getServerInfo()
|
||||
}
|
||||
|
||||
//
|
||||
// Monitoring:: publisher side
|
||||
// Monitoring: publisher side
|
||||
//
|
||||
|
||||
Json::Value NetworkOPs::pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID)
|
||||
{
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
jvObj["type"] = "accountInfoBootstrap";
|
||||
jvObj["account"] = naAccountID.humanAccountID();
|
||||
jvObj["owner"] = getOwnerInfo(lpAccepted, naAccountID);
|
||||
jvObj["seq"] = lpAccepted->getLedgerSeq();
|
||||
jvObj["hash"] = lpAccepted->getHash().ToString();
|
||||
jvObj["time"] = Json::Value::UInt(lpAccepted->getCloseTimeNC());
|
||||
|
||||
return jvObj;
|
||||
}
|
||||
|
||||
void NetworkOPs::pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj)
|
||||
{
|
||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
@@ -827,6 +845,24 @@ void NetworkOPs::pubLedger(const Ledger::pointer& lpAccepted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Publish bootsrap information for accounts.
|
||||
{
|
||||
boost::interprocess::scoped_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
|
||||
BOOST_FOREACH(const subInfoMapType::iterator::value_type& it, mBootAccountInfo)
|
||||
{
|
||||
Json::Value jvObj = pubBootstrapAccountInfo(lpAccepted, NewcoinAddress::createAccountID(it.first));
|
||||
|
||||
BOOST_FOREACH(InfoSub* ispListener, it.second)
|
||||
{
|
||||
ispListener->send(jvObj);
|
||||
}
|
||||
}
|
||||
mBootAccountInfo.clear();
|
||||
}
|
||||
|
||||
// XXX Publish delta information for accounts.
|
||||
}
|
||||
|
||||
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TransactionEngineResult terResult, const std::string& strStatus, int iSeq, const std::string& strType)
|
||||
@@ -917,7 +953,26 @@ void NetworkOPs::subAccountInfo(InfoSub* ispListener, const boost::unordered_set
|
||||
|
||||
BOOST_FOREACH(const NewcoinAddress& naAccountID, vnaAccountIDs)
|
||||
{
|
||||
subInfoMapType::iterator simIterator = mSubAccountInfo.find(naAccountID.getAccountID());
|
||||
// Register for bootstrap info.
|
||||
subInfoMapType::iterator simIterator;
|
||||
|
||||
simIterator = mBootAccountInfo.find(naAccountID.getAccountID());
|
||||
if (simIterator == mBootAccountInfo.end())
|
||||
{
|
||||
// Not found
|
||||
boost::unordered_set<InfoSub*> usisElement;
|
||||
|
||||
usisElement.insert(ispListener);
|
||||
mBootAccountInfo.insert(simIterator, make_pair(naAccountID.getAccountID(), usisElement));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Found
|
||||
simIterator->second.insert(ispListener);
|
||||
}
|
||||
|
||||
// Register for messages.
|
||||
simIterator = mSubAccountInfo.find(naAccountID.getAccountID());
|
||||
if (simIterator == mSubAccountInfo.end())
|
||||
{
|
||||
// Not found
|
||||
|
||||
@@ -53,12 +53,13 @@ protected:
|
||||
|
||||
void setMode(OperatingMode);
|
||||
|
||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> > subInfoMapType;
|
||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> > subInfoMapType;
|
||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::value_type subInfoMapValue;
|
||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
|
||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
|
||||
|
||||
// XXX Split into more locks.
|
||||
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
|
||||
subInfoMapType mBootAccountInfo;
|
||||
subInfoMapType mSubAccountInfo;
|
||||
subInfoMapType mSubAccountTransaction;
|
||||
boost::unordered_set<InfoSub*> mSubLedger; // ledger accepteds
|
||||
@@ -70,6 +71,8 @@ protected:
|
||||
void pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState);
|
||||
void pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState);
|
||||
|
||||
Json::Value pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID);
|
||||
|
||||
public:
|
||||
NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster);
|
||||
|
||||
@@ -123,6 +126,7 @@ public:
|
||||
//
|
||||
|
||||
Json::Value getOwnerInfo(const uint256& uLedger, const NewcoinAddress& naAccount);
|
||||
Json::Value getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddress& naAccount);
|
||||
|
||||
//
|
||||
// Ripple functions
|
||||
|
||||
@@ -949,6 +949,7 @@ Json::Value RPCServer::doOfferCancel(const Json::Value ¶ms)
|
||||
}
|
||||
|
||||
// owner_info <account>|<nickname>|<account_public_key>
|
||||
// owner_info <seed>|<pass_phrase>|<key> [<index>]
|
||||
Json::Value RPCServer::doOwnerInfo(const Json::Value& params)
|
||||
{
|
||||
std::string strIdent = params[0u].asString();
|
||||
|
||||
Reference in New Issue
Block a user