Skip to content

Commit 82e8baa

Browse files
committed
Avoid boost dynamic_bitset in rest_getutxos
1 parent 99f001e commit 82e8baa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/rest.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "version.h"
1818

1919
#include <boost/algorithm/string.hpp>
20-
#include <boost/dynamic_bitset.hpp>
2120

2221
#include <univalue.h>
2322

@@ -502,7 +501,8 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
502501
vector<unsigned char> bitmap;
503502
vector<CCoin> outs;
504503
std::string bitmapStringRepresentation;
505-
boost::dynamic_bitset<unsigned char> hits(vOutPoints.size());
504+
std::vector<bool> hits;
505+
bitmap.resize((vOutPoints.size() + 7) / 8);
506506
{
507507
LOCK2(cs_main, mempool.cs);
508508

@@ -518,10 +518,11 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
518518
for (size_t i = 0; i < vOutPoints.size(); i++) {
519519
CCoins coins;
520520
uint256 hash = vOutPoints[i].hash;
521+
bool hit = false;
521522
if (view.GetCoins(hash, coins)) {
522523
mempool.pruneSpent(hash, coins);
523524
if (coins.IsAvailable(vOutPoints[i].n)) {
524-
hits[i] = true;
525+
hit = true;
525526
// Safe to index into vout here because IsAvailable checked if it's off the end of the array, or if
526527
// n is valid but points to an already spent output (IsNull).
527528
CCoin coin;
@@ -533,10 +534,11 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
533534
}
534535
}
535536

536-
bitmapStringRepresentation.append(hits[i] ? "1" : "0"); // form a binary string representation (human-readable for json output)
537+
hits.push_back(hit);
538+
bitmapStringRepresentation.append(hit ? "1" : "0"); // form a binary string representation (human-readable for json output)
539+
bitmap[i / 8] |= ((uint8_t)hit) << (i % 8);
537540
}
538541
}
539-
boost::to_block_range(hits, std::back_inserter(bitmap));
540542

541543
switch (rf) {
542544
case RF_BINARY: {

0 commit comments

Comments
 (0)