skip incompatible transaction proposals from backups

This commit is contained in:
Matias Alejo Garcia 2014-07-25 10:39:41 -03:00
commit 5eb8164df2

View file

@ -42,8 +42,11 @@ TxProposal.prototype.setSent = function(sentTxid) {
TxProposal.fromObj = function(o) { TxProposal.fromObj = function(o) {
var t = new TxProposal(o); var t = new TxProposal(o);
var b = new Builder.fromObj(o.builderObj); try {
t.builder = b; t.builder = new Builder.fromObj(o.builderObj);
} catch (e) {
console.log('Ignoring incompatible stored TxProposal:' + JSON.stringify(o.builderObj));
}
return t; return t;
}; };
@ -131,8 +134,8 @@ TxProposal.prototype.mergeMetadata = function(v1, author) {
TxProposal.prototype.countSignatures = function() { TxProposal.prototype.countSignatures = function() {
var tx = this.builder.build(); var tx = this.builder.build();
var ret=0; var ret = 0;
for(var i in tx.ins) { for (var i in tx.ins) {
ret += tx.countInputSignatures(i); ret += tx.countInputSignatures(i);
} }
return ret; return ret;
@ -156,8 +159,10 @@ TxProposals.fromObj = function(o) {
}); });
o.txps.forEach(function(o2) { o.txps.forEach(function(o2) {
var t = TxProposal.fromObj(o2); var t = TxProposal.fromObj(o2);
var id = t.builder.build().getNormalizedHash().toString('hex'); if (id) {
ret.txps[id] = t; var id = t.builder.build().getNormalizedHash().toString('hex');
ret.txps[id] = t;
}
}); });
return ret; return ret;
}; };