Added extern mempool and fixed method name.
This commit is contained in:
parent
801679df75
commit
1c615ac7c0
|
@ -64,15 +64,15 @@ describe('Basic Functionality', function() {
|
||||||
|
|
||||||
describe.only('determine if outpoint is unspent/spent', function() {
|
describe.only('determine if outpoint is unspent/spent', function() {
|
||||||
spentData.forEach(function(data) {
|
spentData.forEach(function(data) {
|
||||||
it('for txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
it('for spent txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
||||||
var spent = bitcoind.isSpent(data.txid, data.outputIndex, true);
|
var spent = bitcoind.isSpent(data.txid, data.outputIndex, true);
|
||||||
spent.should.equal(true);
|
spent.should.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unspentData.forEach(function(data) {
|
unspentData.forEach(function(data) {
|
||||||
it('for txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
it('for unspent txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
||||||
var spent = bitcoind.isSapent(data.txid, data.outputIndex, true);
|
var spent = bitcoind.isSpent(data.txid, data.outputIndex, true);
|
||||||
spent.should.equal(false);
|
spent.should.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,6 +22,7 @@ using namespace v8;
|
||||||
|
|
||||||
extern void WaitForShutdown(boost::thread_group* threadGroup);
|
extern void WaitForShutdown(boost::thread_group* threadGroup);
|
||||||
static termios orig_termios;
|
static termios orig_termios;
|
||||||
|
extern CTxMemPool mempool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node.js Internal Function Templates
|
* Node.js Internal Function Templates
|
||||||
|
@ -951,19 +952,19 @@ NAN_METHOD(IsSpent) {
|
||||||
int outputIndex = args[1]->IntegerValue();
|
int outputIndex = args[1]->IntegerValue();
|
||||||
bool queryMempool = args[2]->BooleanValue();
|
bool queryMempool = args[2]->BooleanValue();
|
||||||
|
|
||||||
CCoinsViewCache &view = *pcoinsTip;
|
CCoinsView dummy;
|
||||||
|
CCoinsViewCache view(&dummy);
|
||||||
|
|
||||||
|
CCoinsViewMemPool viewMemPool(pcoinsTip, mempool);
|
||||||
|
view.SetBackend(viewMemPool);
|
||||||
|
|
||||||
if (view.HaveCoins(txid)) {
|
if (view.HaveCoins(txid)) {
|
||||||
const CCoins* coins = view.AccessCoins(txid);
|
const CCoins* coins = view.AccessCoins(txid);
|
||||||
if (!coins || !coins->IsAvailable(outputIndex)) {
|
if (coins && coins->IsAvailable(outputIndex)) {
|
||||||
NanReturnValue(NanNew<Boolean>(false));
|
NanReturnValue(NanNew<Boolean>(false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
NanReturnValue(NanNew<Boolean>(false));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NanReturnValue(NanNew<Boolean>(true));
|
NanReturnValue(NanNew<Boolean>(true));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue