mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
Use DataStream where possible
This commit is contained in:
20
src/rest.cpp
20
src/rest.cpp
@@ -236,7 +236,7 @@ static bool rest_headers(const std::any& context,
|
||||
|
||||
switch (rf) {
|
||||
case RESTResponseFormat::BINARY: {
|
||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssHeader{};
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
ssHeader << pindex->GetBlockHeader();
|
||||
}
|
||||
@@ -248,7 +248,7 @@ static bool rest_headers(const std::any& context,
|
||||
}
|
||||
|
||||
case RESTResponseFormat::HEX: {
|
||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssHeader{};
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
ssHeader << pindex->GetBlockHeader();
|
||||
}
|
||||
@@ -435,7 +435,7 @@ static bool rest_filter_header(const std::any& context, HTTPRequest* req, const
|
||||
|
||||
switch (rf) {
|
||||
case RESTResponseFormat::BINARY: {
|
||||
CDataStream ssHeader{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream ssHeader{};
|
||||
for (const uint256& header : filter_headers) {
|
||||
ssHeader << header;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ static bool rest_filter_header(const std::any& context, HTTPRequest* req, const
|
||||
return true;
|
||||
}
|
||||
case RESTResponseFormat::HEX: {
|
||||
CDataStream ssHeader{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream ssHeader{};
|
||||
for (const uint256& header : filter_headers) {
|
||||
ssHeader << header;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ static bool rest_block_filter(const std::any& context, HTTPRequest* req, const s
|
||||
|
||||
switch (rf) {
|
||||
case RESTResponseFormat::BINARY: {
|
||||
CDataStream ssResp{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream ssResp{};
|
||||
ssResp << filter;
|
||||
|
||||
std::string binaryResp = ssResp.str();
|
||||
@@ -543,7 +543,7 @@ static bool rest_block_filter(const std::any& context, HTTPRequest* req, const s
|
||||
return true;
|
||||
}
|
||||
case RESTResponseFormat::HEX: {
|
||||
CDataStream ssResp{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream ssResp{};
|
||||
ssResp << filter;
|
||||
|
||||
std::string strHex = HexStr(ssResp) + "\n";
|
||||
@@ -793,7 +793,7 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
||||
if (fInputParsed) //don't allow sending input over URI and HTTP RAW DATA
|
||||
return RESTERR(req, HTTP_BAD_REQUEST, "Combination of URI scheme inputs and raw post data is not allowed");
|
||||
|
||||
CDataStream oss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream oss{};
|
||||
oss << strRequestMutable;
|
||||
oss >> fCheckMemPool;
|
||||
oss >> vOutPoints;
|
||||
@@ -866,7 +866,7 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
||||
case RESTResponseFormat::BINARY: {
|
||||
// serialize data
|
||||
// use exact same output as mentioned in Bip64
|
||||
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssGetUTXOResponse{};
|
||||
ssGetUTXOResponse << active_height << active_hash << bitmap << outs;
|
||||
std::string ssGetUTXOResponseString = ssGetUTXOResponse.str();
|
||||
|
||||
@@ -876,7 +876,7 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
||||
}
|
||||
|
||||
case RESTResponseFormat::HEX: {
|
||||
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssGetUTXOResponse{};
|
||||
ssGetUTXOResponse << active_height << active_hash << bitmap << outs;
|
||||
std::string strHex = HexStr(ssGetUTXOResponse) + "\n";
|
||||
|
||||
@@ -946,7 +946,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
|
||||
}
|
||||
switch (rf) {
|
||||
case RESTResponseFormat::BINARY: {
|
||||
CDataStream ss_blockhash(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ss_blockhash{};
|
||||
ss_blockhash << pblockindex->GetBlockHash();
|
||||
req->WriteHeader("Content-Type", "application/octet-stream");
|
||||
req->WriteReply(HTTP_OK, ss_blockhash.str());
|
||||
|
||||
Reference in New Issue
Block a user