skip incompatible transaction proposals from backups

This commit is contained in:
Matias Alejo Garcia 2014-07-25 10:39:41 -03:00
parent b788c76d91
commit 5eb8164df2
1 changed files with 11 additions and 6 deletions

View File

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