better broadcast schema

This commit is contained in:
Matias Alejo Garcia 2014-04-20 16:34:46 -03:00
commit a3dffc65ef

View file

@ -50,17 +50,17 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
var inPKR = copay.PublicKeyRing.fromObj(data.publicKeyRing); var inPKR = copay.PublicKeyRing.fromObj(data.publicKeyRing);
var hasChanged = pkr.merge(inPKR, true); var hasChanged = pkr.merge(inPKR, true);
if (hasChanged && !data.isBroadcast) { if (hasChanged) {
this.log('### BROADCASTING PKR'); this.log('### BROADCASTING PKR');
recipients = null; recipients = null;
shouldSend = true; shouldSend = true;
} }
else if (isInbound && !data.isBroadcast) { // else if (isInbound && !data.isBroadcast) {
// always replying to connecting peer // // always replying to connecting peer
this.log('### REPLYING PKR TO:', senderId); // this.log('### REPLYING PKR TO:', senderId);
recipients = senderId; // recipients = senderId;
shouldSend = true; // shouldSend = true;
} // }
if (shouldSend) { if (shouldSend) {
this.sendPublicKeyRing(recipients); this.sendPublicKeyRing(recipients);
@ -78,17 +78,18 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
var mergeInfo = this.txProposals.merge(inTxp, true); var mergeInfo = this.txProposals.merge(inTxp, true);
var addSeen = this.addSeenToTxProposals(); var addSeen = this.addSeenToTxProposals();
if ((mergeInfo.merged && !data.isBroadcast) || addSeen) { // if ((mergeInfo.merged && !data.isBroadcast) || addSeen) {
if (mergeInfo.merged || addSeen) {
this.log('### BROADCASTING txProposals. ' ); this.log('### BROADCASTING txProposals. ' );
recipients = null; recipients = null;
shouldSend = true; shouldSend = true;
} }
else if (isInbound && !data.isBroadcast) { // else if (isInbound && !data.isBroadcast) {
// always replying to connecting peer // // always replying to connecting peer
this.log('### REPLYING txProposals TO:', senderId); // this.log('### REPLYING txProposals TO:', senderId);
recipients = senderId; // recipients = senderId;
shouldSend = true; // shouldSend = true;
} // }
if (shouldSend) if (shouldSend)
this.sendTxProposals(recipients); this.sendTxProposals(recipients);