mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'faster_clientops'
This commit is contained in:
@@ -29,14 +29,12 @@ void AccountItems::fillItems(const uint160& accountID, Ledger::ref ledger)
|
||||
SLE::pointer ownerDir = ledger->getDirNode(currentIndex);
|
||||
if (!ownerDir) return;
|
||||
|
||||
STVector256 svOwnerNodes = ownerDir->getFieldV256(sfIndexes);
|
||||
|
||||
BOOST_FOREACH(uint256& uNode, svOwnerNodes.peekValue())
|
||||
BOOST_FOREACH(const uint256& uNode, ownerDir->getFieldV256(sfIndexes).peekValue())
|
||||
{
|
||||
SLE::pointer sleCur = ledger->getSLEi(uNode);
|
||||
|
||||
AccountItem::pointer item = mOfType->makeItem(accountID, sleCur);
|
||||
if(item)
|
||||
if (item)
|
||||
{
|
||||
mItems.push_back(item);
|
||||
}
|
||||
|
||||
@@ -2054,7 +2054,7 @@ void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer,
|
||||
newObj.set_ledgerseq(lSeq);
|
||||
}
|
||||
|
||||
if (wantLedger->getAccountHash().isNonZero() && (pack.size() < 768))
|
||||
if (wantLedger->getAccountHash().isNonZero() && (pack.size() < 512))
|
||||
{
|
||||
pack = wantLedger->peekTransactionMap()->getFetchPack(NULL, true, 256);
|
||||
BOOST_FOREACH(SHAMap::fetchPackEntry_t& node, pack)
|
||||
@@ -2065,11 +2065,11 @@ void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer,
|
||||
newObj.set_ledgerseq(lSeq);
|
||||
}
|
||||
}
|
||||
if (reply.objects().size() >= 512)
|
||||
if (reply.objects().size() >= 256)
|
||||
break;
|
||||
haveLedger = wantLedger;
|
||||
wantLedger = getLedgerByHash(haveLedger->getParentHash());
|
||||
} while (wantLedger);
|
||||
} while (wantLedger && (upTime() <= (uUptime + 1)));
|
||||
|
||||
cLog(lsINFO) << "Built fetch pack with " << reply.objects().size() << " nodes";
|
||||
PackedMessage::pointer msg = boost::make_shared<PackedMessage>(reply, ripple::mtGET_OBJECTS);
|
||||
|
||||
@@ -15,9 +15,9 @@ public:
|
||||
AccountItem::pointer makeItem(const uint160&, SerializedLedgerEntry::ref ledgerEntry);
|
||||
LedgerEntryType getType(){ return(ltOFFER); }
|
||||
|
||||
STAmount getTakerPays(){ return(mTakerPays); }
|
||||
STAmount getTakerGets(){ return(mTakerGets); }
|
||||
RippleAddress getAccount(){ return(mAccount); }
|
||||
const STAmount& getTakerPays(){ return(mTakerPays); }
|
||||
const STAmount& getTakerGets(){ return(mTakerGets); }
|
||||
const RippleAddress& getAccount(){ return(mAccount); }
|
||||
int getSeq(){ return(mSeq); }
|
||||
Json::Value getJson(int);
|
||||
|
||||
|
||||
@@ -1608,7 +1608,7 @@ void Peer::recvGetLedger(ripple::TMGetLedger& packet)
|
||||
SHAMapNode mn(packet.nodeids(i).data(), packet.nodeids(i).size());
|
||||
if(!mn.isValid())
|
||||
{
|
||||
cLog(lsWARNING) << "Request for invalid node";
|
||||
cLog(lsWARNING) << "Request for invalid node: " << logMe;
|
||||
punishPeer(LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1148,9 +1148,6 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest, int& cost, Scoped
|
||||
|
||||
AccountState::pointer as = mNetOps->getAccountState(lpLedger, raAccount);
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
if (as)
|
||||
{
|
||||
Json::Value& jsonLines = (jvResult["offers"] = Json::arrayValue);
|
||||
@@ -1160,15 +1157,10 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest, int& cost, Scoped
|
||||
{
|
||||
Offer* offer=(Offer*)item.get();
|
||||
|
||||
STAmount takerPays = offer->getTakerPays();
|
||||
STAmount takerGets = offer->getTakerGets();
|
||||
//RippleAddress account = offer->getAccount();
|
||||
|
||||
Json::Value& obj = jsonLines.append(Json::objectValue);
|
||||
|
||||
//obj["account"] = account.humanAccountID();
|
||||
takerPays.setJson(obj["taker_pays"]);
|
||||
takerGets.setJson(obj["taker_gets"]);
|
||||
offer->getTakerPays().setJson(obj["taker_pays"]);
|
||||
offer->getTakerGets().setJson(obj["taker_gets"]);
|
||||
obj["seq"] = offer->getSeq();
|
||||
|
||||
}
|
||||
|
||||
@@ -377,7 +377,8 @@ protected:
|
||||
SHAMapItem::pointer onlyBelow(SHAMapTreeNode*);
|
||||
void eraseChildren(SHAMapTreeNode::pointer);
|
||||
void dropBelow(SHAMapTreeNode*);
|
||||
bool hasNode(const SHAMapNode& id, const uint256& hash);
|
||||
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);
|
||||
|
||||
@@ -410,7 +410,7 @@ bool SHAMap::deepCompare(SHAMap& other)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SHAMap::hasNode(const SHAMapNode& nodeID, const uint256& nodeHash)
|
||||
bool SHAMap::hasInnerNode(const SHAMapNode& nodeID, const uint256& nodeHash)
|
||||
{
|
||||
SHAMapTreeNode* node = root.get();
|
||||
while (node->isInner() && (node->getDepth() < nodeID.getDepth()))
|
||||
@@ -423,6 +423,19 @@ bool SHAMap::hasNode(const SHAMapNode& nodeID, const uint256& nodeHash)
|
||||
return node->getNodeHash() == nodeHash;
|
||||
}
|
||||
|
||||
bool SHAMap::hasLeafNode(const uint256& tag, const uint256& nodeHash)
|
||||
{
|
||||
SHAMapTreeNode* node = root.get();
|
||||
while (node->isInner())
|
||||
{
|
||||
int branch = node->selectBranch(tag);
|
||||
if (node->isEmptyBranch(branch))
|
||||
return false;
|
||||
node = getNodePointer(node->getChildNodeID(branch), node->getChildHash(branch));
|
||||
}
|
||||
return node->getNodeHash() == nodeHash;
|
||||
}
|
||||
|
||||
std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool includeLeaves, int max)
|
||||
{
|
||||
std::list<fetchPackEntry_t> ret;
|
||||
@@ -446,7 +459,7 @@ std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool incl
|
||||
if (root->isLeaf())
|
||||
{
|
||||
if (includeLeaves && !root->getNodeHash().isZero() &&
|
||||
(!have || !have->hasNode(*root, root->getNodeHash())))
|
||||
(!have || !have->hasLeafNode(root->getTag(), root->getNodeHash())))
|
||||
{
|
||||
Serializer s;
|
||||
root->addRaw(s, snfPREFIX);
|
||||
@@ -486,10 +499,10 @@ std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool incl
|
||||
SHAMapTreeNode *next = getNodePointer(childID, childHash);
|
||||
if (next->isInner())
|
||||
{
|
||||
if (!have || !have->hasNode(*next, childHash))
|
||||
if (!have || !have->hasInnerNode(*next, childHash))
|
||||
stack.push(next);
|
||||
}
|
||||
else if (includeLeaves && (!have || !have->hasNode(childID, childHash)))
|
||||
else if (includeLeaves && (!have || !have->hasLeafNode(next->getTag(), childHash)))
|
||||
{
|
||||
Serializer s;
|
||||
node->addRaw(s, snfPREFIX);
|
||||
|
||||
@@ -639,38 +639,40 @@ std::vector<unsigned char> STObject::getFieldVL(SField::ref field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
static const STAmount defaultAmount;
|
||||
const STAmount& STObject::getFieldAmount(SField::ref field) const
|
||||
{
|
||||
static STAmount empty;
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf)
|
||||
throw std::runtime_error("Field not found");
|
||||
SerializedTypeID id = rf->getSType();
|
||||
if (id == STI_NOTPRESENT)
|
||||
return defaultAmount; // optional field not present
|
||||
return empty; // optional field not present
|
||||
const STAmount *cf = dynamic_cast<const STAmount *>(rf);
|
||||
if (!cf)
|
||||
throw std::runtime_error("Wrong field type");
|
||||
return *cf;
|
||||
}
|
||||
|
||||
STPathSet STObject::getFieldPathSet(SField::ref field) const
|
||||
const STPathSet& STObject::getFieldPathSet(SField::ref field) const
|
||||
{
|
||||
static STPathSet empty;
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
SerializedTypeID id = rf->getSType();
|
||||
if (id == STI_NOTPRESENT) return STPathSet(); // optional field not present
|
||||
if (id == STI_NOTPRESENT) return empty; // optional field not present
|
||||
const STPathSet *cf = dynamic_cast<const STPathSet *>(rf);
|
||||
if (!cf) throw std::runtime_error("Wrong field type");
|
||||
return *cf;
|
||||
}
|
||||
|
||||
STVector256 STObject::getFieldV256(SField::ref field) const
|
||||
const STVector256& STObject::getFieldV256(SField::ref field) const
|
||||
{
|
||||
static STVector256 empty;
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
SerializedTypeID id = rf->getSType();
|
||||
if (id == STI_NOTPRESENT) return STVector256(); // optional field not present
|
||||
if (id == STI_NOTPRESENT) return empty; // optional field not present
|
||||
const STVector256 *cf = dynamic_cast<const STVector256 *>(rf);
|
||||
if (!cf) throw std::runtime_error("Wrong field type");
|
||||
return *cf;
|
||||
|
||||
@@ -131,8 +131,8 @@ public:
|
||||
uint160 getFieldAccount160(SField::ref field) const;
|
||||
std::vector<unsigned char> getFieldVL(SField::ref field) const;
|
||||
const STAmount& getFieldAmount(SField::ref field) const;
|
||||
STPathSet getFieldPathSet(SField::ref field) const;
|
||||
STVector256 getFieldV256(SField::ref field) const;
|
||||
const STPathSet& getFieldPathSet(SField::ref field) const;
|
||||
const STVector256& getFieldV256(SField::ref field) const;
|
||||
|
||||
void setFieldU8(SField::ref field, unsigned char);
|
||||
void setFieldU16(SField::ref field, uint16);
|
||||
|
||||
Reference in New Issue
Block a user