mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Use DataStream where possible
This commit is contained in:
parent
fa9becfe1c
commit
fa29e73cda
48 changed files with 144 additions and 151 deletions
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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue