mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Properly lock cs_main in rest_block
This commit is contained in:
parent
7715c84747
commit
e2f30d547f
@ -11,6 +11,7 @@
|
||||
#include "core/transaction.h"
|
||||
#include "version.h"
|
||||
#include "main.h"
|
||||
#include "sync.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace json_spirit;
|
||||
@ -80,13 +81,17 @@ static bool rest_block(AcceptedConnection *conn,
|
||||
if (!ParseHashStr(hashStr, hash))
|
||||
throw RESTERR(HTTP_BAD_REQUEST, "Invalid hash: " + hashStr);
|
||||
|
||||
CBlock block;
|
||||
CBlockIndex* pblockindex = NULL;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (mapBlockIndex.count(hash) == 0)
|
||||
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
||||
|
||||
CBlock block;
|
||||
CBlockIndex* pblockindex = mapBlockIndex[hash];
|
||||
pblockindex = mapBlockIndex[hash];
|
||||
if (!ReadBlockFromDisk(block, pblockindex))
|
||||
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
||||
}
|
||||
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssBlock << block;
|
||||
|
Loading…
Reference in New Issue
Block a user