Skip to content

Commit

Permalink
fix for tx confirmations when cache enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pointbiz committed Apr 22, 2021
1 parent 789f643 commit ac9ad18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/api/rpcApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function getBlockchainInfo() {

}

function getBlockCount() {
return getRpcData("getblockcount");
}

function getNetworkInfo() {
return getRpcData("getnetworkinfo");
}
Expand Down Expand Up @@ -572,6 +576,7 @@ module.exports = {
getRpcDataWithParams: getRpcDataWithParams,

getBlockchainInfo: getBlockchainInfo,
getBlockCount: getBlockCount,
getNetworkInfo: getNetworkInfo,
getNetTotals: getNetTotals,
getMempoolInfo: getMempoolInfo,
Expand Down
15 changes: 12 additions & 3 deletions routes/baseRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,22 @@ router.get("/tx/:transactionId", asyncHandler(async (req, res, next) => {
if (err3) return reject(err3);
res.locals.result.getblock = result3;

resolve();
resolve(result3);
});
}));
}).then(function(blockheader) {
// fix confirmations for cached transactions
if (!config.noInmemoryRpcCache) {
rpcApi.getBlockCount().then(function(blockcount){
var confs = blockcount - blockheader.height + 1;
res.locals.tx.confirmations = confs;
res.locals.result.getrawtransaction.confirmations = confs;
});
}
}))
}

await Promise.all(promises);

res.render("transaction");

next();
Expand Down

0 comments on commit ac9ad18

Please sign in to comment.