Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 557 Lines • ▼ Show 20 Lines | static bool rest_getutxos(Config &config, HTTPRequest *req, | ||||
// check spentness and form a bitmap (as well as a JSON capable | // check spentness and form a bitmap (as well as a JSON capable | ||||
// human-readable string representation) | // human-readable string representation) | ||||
std::vector<uint8_t> bitmap; | std::vector<uint8_t> bitmap; | ||||
std::vector<CCoin> outs; | std::vector<CCoin> outs; | ||||
std::string bitmapStringRepresentation; | std::string bitmapStringRepresentation; | ||||
std::vector<bool> hits; | std::vector<bool> hits; | ||||
bitmap.resize((vOutPoints.size() + 7) / 8); | bitmap.resize((vOutPoints.size() + 7) / 8); | ||||
{ | { | ||||
LOCK2(cs_main, mempool.cs); | LOCK2(cs_main, g_mempool.cs); | ||||
CCoinsView viewDummy; | CCoinsView viewDummy; | ||||
CCoinsViewCache view(&viewDummy); | CCoinsViewCache view(&viewDummy); | ||||
CCoinsViewCache &viewChain = *pcoinsTip; | CCoinsViewCache &viewChain = *pcoinsTip; | ||||
CCoinsViewMemPool viewMempool(&viewChain, mempool); | CCoinsViewMemPool viewMempool(&viewChain, g_mempool); | ||||
if (fCheckMemPool) { | if (fCheckMemPool) { | ||||
// switch cache backend to db+mempool in case user likes to query | // switch cache backend to db+mempool in case user likes to query | ||||
// mempool. | // mempool. | ||||
view.SetBackend(viewMempool); | view.SetBackend(viewMempool); | ||||
} | } | ||||
for (size_t i = 0; i < vOutPoints.size(); i++) { | for (size_t i = 0; i < vOutPoints.size(); i++) { | ||||
Coin coin; | Coin coin; | ||||
bool hit = false; | bool hit = false; | ||||
if (view.GetCoin(vOutPoints[i], coin) && | if (view.GetCoin(vOutPoints[i], coin) && | ||||
!mempool.isSpent(vOutPoints[i])) { | !g_mempool.isSpent(vOutPoints[i])) { | ||||
hit = true; | hit = true; | ||||
outs.emplace_back(std::move(coin)); | outs.emplace_back(std::move(coin)); | ||||
} | } | ||||
hits.push_back(hit); | hits.push_back(hit); | ||||
// form a binary string representation (human-readable for json | // form a binary string representation (human-readable for json | ||||
// output) | // output) | ||||
bitmapStringRepresentation.append(hit ? "1" : "0"); | bitmapStringRepresentation.append(hit ? "1" : "0"); | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |