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() {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue