From 6d772a3d441875fbdcd7c15aaa8d9b97f61aa3a9 Mon Sep 17 00:00:00 2001 From: Jim Posen Date: Fri, 8 Dec 2017 11:49:08 -0800 Subject: [rpc] Public interfaces to GetTransaction block until synced. Now that the transaction index is updated asynchronously, in order to preserve the current behavior of public interfaces, the code blocks until the transaction index is caught up with the current state of the blockchain. --- src/rest.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/rest.cpp') diff --git a/src/rest.cpp b/src/rest.cpp index 5871b554a..095655b3a 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -350,6 +351,10 @@ static bool rest_tx(HTTPRequest* req, const std::string& strURIPart) if (!ParseHashStr(hashStr, hash)) return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); + if (g_txindex) { + g_txindex->BlockUntilSyncedToCurrentChain(); + } + CTransactionRef tx; uint256 hashBlock = uint256(); if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true)) -- cgit v1.2.3