fix getBlockByTx.
This commit is contained in:
parent
0508bc54d8
commit
70d19eb6d6
@ -445,7 +445,7 @@ Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback)
|
|||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
if (slow && !tx.blockhash) {
|
if (slow && !tx.blockhash) {
|
||||||
return bitcoindjs.getBlockByTx(txid, function(err, block) {
|
return bitcoindjs.getBlockByTx(txid, function(err, block, tx_) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
return callback(null, bitcoin.tx(tx), bitcoin.block(block));
|
return callback(null, bitcoin.tx(tx), bitcoin.block(block));
|
||||||
});
|
});
|
||||||
@ -553,12 +553,18 @@ Bitcoin.prototype.getBlockByTxid =
|
|||||||
Bitcoin.prototype.getBlockByTx = function(txid, callback) {
|
Bitcoin.prototype.getBlockByTx = function(txid, callback) {
|
||||||
return bitcoin.db.get('block-tx/' + txid, function(err, block) {
|
return bitcoin.db.get('block-tx/' + txid, function(err, block) {
|
||||||
if (block) {
|
if (block) {
|
||||||
return self.getBlock(block.hash, callback);
|
return self.getBlock(block.hash, function(err, block) {
|
||||||
|
if (err) return callback(err);
|
||||||
|
var tx_ = block.tx.filter(function(tx) {
|
||||||
|
return tx.txid === txid;
|
||||||
|
})[0];
|
||||||
|
return callback(null, block, tx_);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return bitcoindjs.getBlockByTx(txid, function(err, block) {
|
return bitcoindjs.getBlockByTx(txid, function(err, block, tx_) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
bitcoin.db.set('block-tx/' + txid, { hash: block.hash }, utils.NOOP);
|
bitcoin.db.set('block-tx/' + txid, { hash: block.hash }, utils.NOOP);
|
||||||
return callback(null, bitcoin.block(block));
|
return callback(null, bitcoin.block(block), bitcoin.tx(tx_));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2276,7 +2276,7 @@ async_block_tx_after(uv_work_t *req) {
|
|||||||
Local<Object> jstx = NanNew<Object>();
|
Local<Object> jstx = NanNew<Object>();
|
||||||
ctx_to_jstx(ctx, cblock.GetHash(), jstx);
|
ctx_to_jstx(ctx, cblock.GetHash(), jstx);
|
||||||
|
|
||||||
const unsigned argc = 2;
|
const unsigned argc = 3;
|
||||||
Local<Value> argv[argc] = {
|
Local<Value> argv[argc] = {
|
||||||
Local<Value>::New(Null()),
|
Local<Value>::New(Null()),
|
||||||
Local<Value>::New(jsblock),
|
Local<Value>::New(jsblock),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user