|
|
@ -11,6 +11,7 @@
|
|
|
|
#include "core/transaction.h"
|
|
|
|
#include "core/transaction.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include "sync.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
using namespace json_spirit;
|
|
|
|
using namespace json_spirit;
|
|
|
@ -80,13 +81,17 @@ static bool rest_block(AcceptedConnection *conn,
|
|
|
|
if (!ParseHashStr(hashStr, hash))
|
|
|
|
if (!ParseHashStr(hashStr, hash))
|
|
|
|
throw RESTERR(HTTP_BAD_REQUEST, "Invalid hash: " + hashStr);
|
|
|
|
throw RESTERR(HTTP_BAD_REQUEST, "Invalid hash: " + hashStr);
|
|
|
|
|
|
|
|
|
|
|
|
if (mapBlockIndex.count(hash) == 0)
|
|
|
|
|
|
|
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CBlock block;
|
|
|
|
CBlock block;
|
|
|
|
CBlockIndex* pblockindex = mapBlockIndex[hash];
|
|
|
|
CBlockIndex* pblockindex = NULL;
|
|
|
|
if (!ReadBlockFromDisk(block, pblockindex))
|
|
|
|
{
|
|
|
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
|
|
|
LOCK(cs_main);
|
|
|
|
|
|
|
|
if (mapBlockIndex.count(hash) == 0)
|
|
|
|
|
|
|
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pblockindex = mapBlockIndex[hash];
|
|
|
|
|
|
|
|
if (!ReadBlockFromDisk(block, pblockindex))
|
|
|
|
|
|
|
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
ssBlock << block;
|
|
|
|
ssBlock << block;
|
|
|
|