add purge to tx prosposals

This commit is contained in:
Matias Alejo Garcia 2014-08-21 13:12:55 -04:00
commit 4931c9d618
6 changed files with 114 additions and 6 deletions

View file

@ -36,10 +36,25 @@ TxProposals.fromObj = function(o, forceOpts) {
return ret;
};
TxProposals.prototype.length = function() {
return Object.keys(this.txps).length;
};
TxProposals.prototype.getNtxids = function() {
return Object.keys(this.txps);
};
TxProposals.prototype.deleteAll = function() {
this.txps = {};
};
TxProposals.prototype.deletePending = function(maxRejectCount) {
for (var ntxid in this.txps) {
if (this.txps[ntxid].isPending(maxRejectCount))
delete this.txps[ntxid];
};
};
TxProposals.prototype.toObj = function() {
var ret = [];
for (var id in this.txps) {
@ -153,7 +168,8 @@ TxProposals.prototype.getUsedUnspent = function(maxRejectCount) {
for (var i in this.txps) {
var u = this.txps[i].builder.getSelectedUnspent();
var p = this.getTxProposal(i);
if (p.rejectCount > maxRejectCount || p.sentTxid)
if (!p.isPending(maxRejectCount))
continue;
for (var j in u) {