File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -1542,25 +1542,19 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
1542
1542
const CBlockIndex* pindex;
1543
1543
int blockcount = 30 * 24 * 60 * 60 / Params ().GetConsensus ().nPowTargetSpacing ; // By default: 1 month
1544
1544
1545
- bool havehash = !request.params [1 ].isNull ();
1546
- uint256 hash;
1547
- if (havehash) {
1548
- hash = uint256S (request.params [1 ].get_str ());
1549
- }
1550
-
1551
- {
1545
+ if (request.params [1 ].isNull ()) {
1552
1546
LOCK (cs_main);
1553
- if (havehash) {
1554
- auto it = mapBlockIndex. find (hash);
1555
- if (it == mapBlockIndex. end ()) {
1556
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found " );
1557
- }
1558
- pindex = it-> second ;
1559
- if (!chainActive. Contains (pindex)) {
1560
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Block is not in main chain " );
1561
- }
1562
- } else {
1563
- pindex = chainActive. Tip ( );
1547
+ pindex = chainActive. Tip ();
1548
+ } else {
1549
+ uint256 hash = uint256S (request. params [ 1 ]. get_str ());
1550
+ LOCK (cs_main );
1551
+ auto it = mapBlockIndex. find (hash);
1552
+ if (it == mapBlockIndex. end ()) {
1553
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found " );
1554
+ }
1555
+ pindex = it-> second ;
1556
+ if (!chainActive. Contains (pindex)) {
1557
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Block is not in main chain " );
1564
1558
}
1565
1559
}
1566
1560
You can’t perform that action at this time.
0 commit comments