Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void entryToJSON(const CTxMemPool &pool, UniValue &info, | static void entryToJSON(const CTxMemPool &pool, UniValue &info, | ||||
const CTxMemPoolEntry &e) | const CTxMemPoolEntry &e) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | ||||
AssertLockHeld(pool.cs); | AssertLockHeld(pool.cs); | ||||
UniValue fees(UniValue::VOBJ); | UniValue fees(UniValue::VOBJ); | ||||
fees.pushKV("base", ValueFromAmount(e.GetFee())); | fees.pushKV("base", ValueFromAmount(e.GetFee()), false); | ||||
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee())); | fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()), false); | ||||
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors())); | fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()), | ||||
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants())); | false); | ||||
info.pushKV("fees", fees); | fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()), | ||||
false); | |||||
info.pushKV("size", (int)e.GetTxSize()); | info.pushKV("fees", fees, false); | ||||
info.pushKV("fee", ValueFromAmount(e.GetFee())); | |||||
info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee())); | info.pushKV("size", (int)e.GetTxSize(), false); | ||||
info.pushKV("time", e.GetTime()); | info.pushKV("fee", ValueFromAmount(e.GetFee()), false); | ||||
info.pushKV("height", (int)e.GetHeight()); | info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee()), false); | ||||
info.pushKV("descendantcount", e.GetCountWithDescendants()); | info.pushKV("time", e.GetTime(), false); | ||||
info.pushKV("descendantsize", e.GetSizeWithDescendants()); | info.pushKV("height", (int)e.GetHeight(), false); | ||||
info.pushKV("descendantfees", e.GetModFeesWithDescendants() / SATOSHI); | info.pushKV("descendantcount", e.GetCountWithDescendants(), false); | ||||
info.pushKV("ancestorcount", e.GetCountWithAncestors()); | info.pushKV("descendantsize", e.GetSizeWithDescendants(), false); | ||||
info.pushKV("ancestorsize", e.GetSizeWithAncestors()); | info.pushKV("descendantfees", e.GetModFeesWithDescendants() / SATOSHI, | ||||
info.pushKV("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI); | false); | ||||
info.pushKV("ancestorcount", e.GetCountWithAncestors(), false); | |||||
info.pushKV("ancestorsize", e.GetSizeWithAncestors(), false); | |||||
info.pushKV("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI, false); | |||||
const CTransaction &tx = e.GetTx(); | const CTransaction &tx = e.GetTx(); | ||||
std::set<std::string> setDepends; | std::set<std::string> setDepends; | ||||
for (const CTxIn &txin : tx.vin) { | for (const CTxIn &txin : tx.vin) { | ||||
if (pool.exists(txin.prevout.GetTxId())) { | if (pool.exists(txin.prevout.GetTxId())) { | ||||
setDepends.insert(txin.prevout.GetTxId().ToString()); | setDepends.insert(txin.prevout.GetTxId().ToString()); | ||||
} | } | ||||
} | } | ||||
UniValue depends(UniValue::VARR); | UniValue depends(UniValue::VARR); | ||||
for (const std::string &dep : setDepends) { | for (const std::string &dep : setDepends) { | ||||
depends.push_back(dep); | depends.push_back(dep); | ||||
} | } | ||||
info.pushKV("depends", depends); | info.pushKV("depends", depends, false); | ||||
UniValue spent(UniValue::VARR); | UniValue spent(UniValue::VARR); | ||||
const CTxMemPool::txiter &it = pool.mapTx.find(tx.GetId()); | const CTxMemPool::txiter &it = pool.mapTx.find(tx.GetId()); | ||||
const CTxMemPool::setEntries &setChildren = pool.GetMemPoolChildren(it); | const CTxMemPool::setEntries &setChildren = pool.GetMemPoolChildren(it); | ||||
for (CTxMemPool::txiter childiter : setChildren) { | for (CTxMemPool::txiter childiter : setChildren) { | ||||
spent.push_back(childiter->GetTx().GetId().ToString()); | spent.push_back(childiter->GetTx().GetId().ToString()); | ||||
} | } | ||||
info.pushKV("spentby", spent); | info.pushKV("spentby", spent, false); | ||||
} | } | ||||
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose) { | UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose) { | ||||
if (verbose) { | if (verbose) { | ||||
LOCK(pool.cs); | LOCK(pool.cs); | ||||
UniValue o(UniValue::VOBJ); | UniValue o(UniValue::VOBJ); | ||||
for (const CTxMemPoolEntry &e : pool.mapTx) { | for (const CTxMemPoolEntry &e : pool.mapTx) { | ||||
const uint256 &txid = e.GetTx().GetId(); | const uint256 &txid = e.GetTx().GetId(); | ||||
UniValue info(UniValue::VOBJ); | UniValue info(UniValue::VOBJ); | ||||
entryToJSON(pool, info, e); | entryToJSON(pool, info, e); | ||||
o.pushKV(txid.ToString(), info); | o.pushKV(txid.ToString(), info, false); | ||||
} | } | ||||
return o; | return o; | ||||
} else { | } else { | ||||
std::vector<uint256> vtxids; | std::vector<uint256> vtxids; | ||||
pool.queryHashes(vtxids); | pool.queryHashes(vtxids); | ||||
UniValue a(UniValue::VARR); | UniValue a(UniValue::VARR); | ||||
for (const uint256 &txid : vtxids) { | for (const uint256 &txid : vtxids) { | ||||
▲ Show 20 Lines • Show All 2,271 Lines • Show Last 20 Lines |