File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 11
11
#include " core/transaction.h"
12
12
#include " version.h"
13
13
#include " main.h"
14
+ #include " sync.h"
14
15
15
16
using namespace std ;
16
17
using namespace json_spirit ;
@@ -80,13 +81,17 @@ static bool rest_block(AcceptedConnection *conn,
80
81
if (!ParseHashStr (hashStr, hash))
81
82
throw RESTERR (HTTP_BAD_REQUEST, " Invalid hash: " + hashStr);
82
83
83
- if (mapBlockIndex.count (hash) == 0 )
84
- throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
85
-
86
84
CBlock block;
87
- CBlockIndex* pblockindex = mapBlockIndex[hash];
88
- if (!ReadBlockFromDisk (block, pblockindex))
89
- throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
85
+ CBlockIndex* pblockindex = NULL ;
86
+ {
87
+ LOCK (cs_main);
88
+ if (mapBlockIndex.count (hash) == 0 )
89
+ throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
90
+
91
+ pblockindex = mapBlockIndex[hash];
92
+ if (!ReadBlockFromDisk (block, pblockindex))
93
+ throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
94
+ }
90
95
91
96
CDataStream ssBlock (SER_NETWORK, PROTOCOL_VERSION);
92
97
ssBlock << block;
You can’t perform that action at this time.
0 commit comments