fix sig cache

This commit is contained in:
Matias Alejo Garcia 2014-12-12 19:14:58 -03:00
commit efd1e9633a
5 changed files with 18 additions and 8 deletions

View file

@ -559,7 +559,9 @@ PublicKeyRing.prototype.getAddressesOrderer = function(pubkey) {
var l = info.length;
var sortedInfo = _.sortBy(info, function(i) {
var goodness = ( (i.copayerIndex !== copayerIndex) ? 2 * l : 0 ) +( i.isChange ? l : 0 ) + l - i.addressIndex;
var goodness = ( (i.copayerIndex !== copayerIndex) ? 2 * l : 0 )
+ ( i.isChange ? l : 0 )
+ l - i.addressIndex;
return goodness;
});

View file

@ -235,6 +235,8 @@ TxProposal.prototype._addSignatureAndVerify = function(signatures) {
var inputsFullySigned = 0;
var newScriptSigs = [];
this.resetCache();
_.each(tx.ins, function(input, index) {
var scriptSig = new Script(input.s);
@ -288,11 +290,9 @@ TxProposal.prototype._addSignatureAndVerify = function(signatures) {
input.s = newScriptSigs[index];
// just to keep TransactionBuilder updated
if (tx.ins.length == inputsFullySigned)
if (tx.ins.length == inputsFullySigned)
self.builder.inputsSigned++;
});
this.resetCache();
};
TxProposal.prototype.resetCache = function() {

View file

@ -412,8 +412,12 @@ Wallet.prototype._checkIfTxIsSent = function(ntxid, cb) {
var tx = txp.builder.build();
var txHex = tx.serialize().toString('hex');
//Use calcHash NOT getHash which could be cached.
var txid = bitcore.util.formatHashFull(tx.calcHash());
log.debug('Checking if transactions was broadcasted... ID:' + txid);
this.blockchain.getTransaction(txid, function(err, tx) {
return cb(err, !err ? txid : null);
});
@ -1625,9 +1629,7 @@ Wallet.prototype.broadcastToBitcoinNetwork = function(ntxid, cb) {
this.blockchain.broadcast(txHex, function(err, txid) {
if (err || !txid) {
log.info('Wallet:' + self.getName() + '. Sent failed:' +
err + '. Checking if the TX was sent already');
log.debug('Wallet:' + self.getName() + ' Send failed:' + err );
self._checkIfTxIsSent(ntxid, function(err, txid) {
return cb(err, txid);