aboutsummaryrefslogtreecommitdiff
path: root/src/rest.cpp
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2017-12-08 11:49:08 -0800
committerJim Posen <jimpo@coinbase.com>2018-04-25 11:25:17 -0700
commit6d772a3d441875fbdcd7c15aaa8d9b97f61aa3a9 (patch)
treec154280fa31e41b205323aff9756312359430fbc /src/rest.cpp
parenta03f804f2aa0261ed3a47103dfe989ebd9302480 (diff)
downloadbitcoin-6d772a3d441875fbdcd7c15aaa8d9b97f61aa3a9.tar.xz
[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.
Diffstat (limited to 'src/rest.cpp')
-rw-r--r--src/rest.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rest.cpp b/src/rest.cpp
index 5871b554a6..095655b3a0 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -6,6 +6,7 @@
#include <chain.h>
#include <chainparams.h>
#include <core_io.h>
+#include <index/txindex.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <validation.h>
@@ -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))