Added extern mempool and fixed method name.

This commit is contained in:
Chris Kleeschulte 2015-07-15 18:52:36 -04:00 committed by Braydon Fuller
parent 801679df75
commit 1c615ac7c0
2 changed files with 10 additions and 9 deletions

View File

@ -64,15 +64,15 @@ describe('Basic Functionality', function() {
describe.only('determine if outpoint is unspent/spent', function() {
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);
spent.should.equal(true);
});
});
unspentData.forEach(function(data) {
it('for txid ' + data.txid + ' and output ' + data.outputIndex, function() {
var spent = bitcoind.isSapent(data.txid, data.outputIndex, true);
it('for unspent txid ' + data.txid + ' and output ' + data.outputIndex, function() {
var spent = bitcoind.isSpent(data.txid, data.outputIndex, true);
spent.should.equal(false);
});
});

View File

@ -22,6 +22,7 @@ using namespace v8;
extern void WaitForShutdown(boost::thread_group* threadGroup);
static termios orig_termios;
extern CTxMemPool mempool;
/**
* Node.js Internal Function Templates
@ -951,19 +952,19 @@ NAN_METHOD(IsSpent) {
int outputIndex = args[1]->IntegerValue();
bool queryMempool = args[2]->BooleanValue();
CCoinsViewCache &view = *pcoinsTip;
CCoinsView dummy;
CCoinsViewCache view(&dummy);
CCoinsViewMemPool viewMemPool(pcoinsTip, mempool);
view.SetBackend(viewMemPool);
if (view.HaveCoins(txid)) {
const CCoins* coins = view.AccessCoins(txid);
if (!coins || !coins->IsAvailable(outputIndex)) {
if (coins && coins->IsAvailable(outputIndex)) {
NanReturnValue(NanNew<Boolean>(false));
return;
}
} else {
NanReturnValue(NanNew<Boolean>(false));
return;
}
NanReturnValue(NanNew<Boolean>(true));
};