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() { 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);
}); });
}); });

View File

@ -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));
}; };