mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
UPSTREAM MERGE BROKEN: Merge commit 'f617e05c38' into master
This commit is contained in:
commit
7f894ae00b
393 changed files with 7992 additions and 3340 deletions
42
src/rest.cpp
42
src/rest.cpp
|
|
@ -16,7 +16,7 @@
|
|||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
#include <txmempool.h>
|
||||
#include <utilstrencodings.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
@ -105,15 +105,6 @@ static std::string AvailableDataFormatsString()
|
|||
return formats;
|
||||
}
|
||||
|
||||
static bool ParseHashStr(const std::string& strReq, uint256& v)
|
||||
{
|
||||
if (!IsHex(strReq) || (strReq.size() != 64))
|
||||
return false;
|
||||
|
||||
v.SetHex(strReq);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CheckWarmup(HTTPRequest* req)
|
||||
{
|
||||
std::string statusmessage;
|
||||
|
|
@ -157,13 +148,13 @@ static bool rest_headers(HTTPRequest* req,
|
|||
}
|
||||
}
|
||||
|
||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
ssHeader << pindex->GetBlockHeader();
|
||||
}
|
||||
|
||||
switch (rf) {
|
||||
case RetFormat::BINARY: {
|
||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
ssHeader << pindex->GetBlockHeader();
|
||||
}
|
||||
|
||||
std::string binaryHeader = ssHeader.str();
|
||||
req->WriteHeader("Content-Type", "application/octet-stream");
|
||||
req->WriteReply(HTTP_OK, binaryHeader);
|
||||
|
|
@ -171,6 +162,11 @@ static bool rest_headers(HTTPRequest* req,
|
|||
}
|
||||
|
||||
case RetFormat::HEX: {
|
||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||
for (const CBlockIndex *pindex : headers) {
|
||||
ssHeader << pindex->GetBlockHeader();
|
||||
}
|
||||
|
||||
std::string strHex = HexStr(ssHeader.begin(), ssHeader.end()) + "\n";
|
||||
req->WriteHeader("Content-Type", "text/plain");
|
||||
req->WriteReply(HTTP_OK, strHex);
|
||||
|
|
@ -224,11 +220,10 @@ static bool rest_block(HTTPRequest* req,
|
|||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||
}
|
||||
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssBlock << block;
|
||||
|
||||
switch (rf) {
|
||||
case RetFormat::BINARY: {
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssBlock << block;
|
||||
std::string binaryBlock = ssBlock.str();
|
||||
req->WriteHeader("Content-Type", "application/octet-stream");
|
||||
req->WriteReply(HTTP_OK, binaryBlock);
|
||||
|
|
@ -236,6 +231,8 @@ static bool rest_block(HTTPRequest* req,
|
|||
}
|
||||
|
||||
case RetFormat::HEX: {
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssBlock << block;
|
||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()) + "\n";
|
||||
req->WriteHeader("Content-Type", "text/plain");
|
||||
req->WriteReply(HTTP_OK, strHex);
|
||||
|
|
@ -360,11 +357,11 @@ static bool rest_tx(HTTPRequest* req, const std::string& strURIPart)
|
|||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssTx << tx;
|
||||
|
||||
switch (rf) {
|
||||
case RetFormat::BINARY: {
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssTx << tx;
|
||||
|
||||
std::string binaryTx = ssTx.str();
|
||||
req->WriteHeader("Content-Type", "application/octet-stream");
|
||||
req->WriteReply(HTTP_OK, binaryTx);
|
||||
|
|
@ -372,6 +369,9 @@ static bool rest_tx(HTTPRequest* req, const std::string& strURIPart)
|
|||
}
|
||||
|
||||
case RetFormat::HEX: {
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssTx << tx;
|
||||
|
||||
std::string strHex = HexStr(ssTx.begin(), ssTx.end()) + "\n";
|
||||
req->WriteHeader("Content-Type", "text/plain");
|
||||
req->WriteReply(HTTP_OK, strHex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue