diff --git a/benchmarks/index.js b/benchmarks/index.js index a6b7ecf4..be32186b 100644 --- a/benchmarks/index.js +++ b/benchmarks/index.js @@ -90,7 +90,7 @@ bitcoind.on('ready', function() { c = 0; } var hash = fixtureData.txHashes[c]; - bitcoind.getTransaction(hash, function(err, tx) { + bitcoind.getTransaction(hash, true, function(err, tx) { if (err) { throw err; } diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 27149c8c..9d1c0b5f 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -328,12 +328,7 @@ Bitcoin.prototype.isSpent = function(txid, outputIndex) { }; Bitcoin.prototype.getTransaction = function(txid, queryMempool, callback) { - return bitcoindjs.getTransaction(txid, queryMempool, function(err, tx) { - if (err) { - return callback(err); - } - return callback(null, tx); - }); + return bitcoindjs.getTransaction(txid, queryMempool, callback); }; Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback) { diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 61d748ed..fcf700a9 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -804,39 +804,35 @@ async_get_tx(uv_work_t *req) { uint256 blockhash; CTransaction ctx; - { - - if (data->queryMempool) { - LOCK(cs_main); + if (data->queryMempool) { + LOCK(cs_main); + { + if (mempool.lookup(hash, ctx)) { - if (mempool.lookup(hash, ctx)) - { - return; - } + return; } } + } - CDiskTxPos postx; - if (pblocktree->ReadTxIndex(hash, postx)) { + CDiskTxPos postx; + if (pblocktree->ReadTxIndex(hash, postx)) { - CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); + CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); - if (file.IsNull()) { - data->err_msg = std::string("%s: OpenBlockFile failed", __func__); - return; - } + if (file.IsNull()) { + data->err_msg = std::string("%s: OpenBlockFile failed", __func__); + return; + } - const int HEADER_SIZE = sizeof(int32_t) + sizeof(uint32_t) * 3 + sizeof(char) * 64; - - try { - fseek(file.Get(), postx.nTxOffset + HEADER_SIZE, SEEK_CUR); - file >> ctx; - data->ctx = ctx; - } catch (const std::exception& e) { - data->err_msg = std::string("Deserialize or I/O error - %s", __func__); - return; - } + const int HEADER_SIZE = sizeof(int32_t) + sizeof(uint32_t) * 3 + sizeof(char) * 64; + try { + fseek(file.Get(), postx.nTxOffset + HEADER_SIZE, SEEK_CUR); + file >> ctx; + data->ctx = ctx; + } catch (const std::exception& e) { + data->err_msg = std::string("Deserialize or I/O error - %s", __func__); + return; } }