mirror of https://github.com/BTCPrivate/copay.git
remove isInbound and use mailbox ts
This commit is contained in:
parent
24a4be065a
commit
439bd3c44f
|
@ -99,7 +99,7 @@ Wallet.prototype.connectToAll = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onIndexes = function(senderId, data, isInbound) {
|
Wallet.prototype._onIndexes = function(senderId, data) {
|
||||||
this.log('RECV INDEXES:', data);
|
this.log('RECV INDEXES:', data);
|
||||||
var inIndexes = HDParams.fromList(data.indexes);
|
var inIndexes = HDParams.fromList(data.indexes);
|
||||||
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
||||||
|
@ -109,7 +109,7 @@ Wallet.prototype._onIndexes = function(senderId, data, isInbound) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onPublicKeyRing = function(senderId, data, isInbound) {
|
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
this.log('RECV PUBLICKEYRING:', data);
|
this.log('RECV PUBLICKEYRING:', data);
|
||||||
|
|
||||||
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
||||||
|
@ -254,7 +254,7 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype._onReject = function(senderId, data, isInbound) {
|
Wallet.prototype._onReject = function(senderId, data) {
|
||||||
preconditions.checkState(data.ntxid);
|
preconditions.checkState(data.ntxid);
|
||||||
this.log('RECV REJECT:', data);
|
this.log('RECV REJECT:', data);
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ Wallet.prototype._onReject = function(senderId, data, isInbound) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onSeen = function(senderId, data, isInbound) {
|
Wallet.prototype._onSeen = function(senderId, data) {
|
||||||
preconditions.checkState(data.ntxid);
|
preconditions.checkState(data.ntxid);
|
||||||
this.log('RECV SEEN:', data);
|
this.log('RECV SEEN:', data);
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ Wallet.prototype._onSeen = function(senderId, data, isInbound) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype._onAddressBook = function(senderId, data, isInbound) {
|
Wallet.prototype._onAddressBook = function(senderId, data) {
|
||||||
preconditions.checkState(data.addressBook);
|
preconditions.checkState(data.addressBook);
|
||||||
this.log('RECV ADDRESSBOOK:', data);
|
this.log('RECV ADDRESSBOOK:', data);
|
||||||
var rcv = data.addressBook;
|
var rcv = data.addressBook;
|
||||||
|
@ -316,17 +316,21 @@ Wallet.prototype._onAddressBook = function(senderId, data, isInbound) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.updateTimestamp = function() {
|
Wallet.prototype.updateTimestamp = function(ts) {
|
||||||
this.lastTimestamp = (new Date().getTime()) * 1000;
|
preconditions.checkArgument(ts);
|
||||||
|
preconditions.checkArgument(typeof ts === 'number');
|
||||||
|
this.lastTimestamp = ts;
|
||||||
this.store();
|
this.store();
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onData = function(senderId, data, isInbound) {
|
Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(senderId);
|
preconditions.checkArgument(senderId);
|
||||||
preconditions.checkArgument(data);
|
preconditions.checkArgument(data);
|
||||||
preconditions.checkArgument(data.type);
|
preconditions.checkArgument(data.type);
|
||||||
|
preconditions.checkArgument(ts);
|
||||||
|
preconditions.checkArgument(typeof ts === 'number');
|
||||||
|
|
||||||
this.updateTimestamp();
|
this.updateTimestamp(ts);
|
||||||
|
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
this.emit('corrupt', senderId);
|
this.emit('corrupt', senderId);
|
||||||
|
@ -344,25 +348,25 @@ Wallet.prototype._onData = function(senderId, data, isInbound) {
|
||||||
this.sendAllTxProposals(senderId); // send old txps
|
this.sendAllTxProposals(senderId); // send old txps
|
||||||
break;
|
break;
|
||||||
case 'publicKeyRing':
|
case 'publicKeyRing':
|
||||||
this._onPublicKeyRing(senderId, data, isInbound);
|
this._onPublicKeyRing(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'reject':
|
case 'reject':
|
||||||
this._onReject(senderId, data, isInbound);
|
this._onReject(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'seen':
|
case 'seen':
|
||||||
this._onSeen(senderId, data, isInbound);
|
this._onSeen(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'txProposal':
|
case 'txProposal':
|
||||||
this._onTxProposal(senderId, data, isInbound);
|
this._onTxProposal(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'indexes':
|
case 'indexes':
|
||||||
this._onIndexes(senderId, data, isInbound);
|
this._onIndexes(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'addressbook':
|
case 'addressbook':
|
||||||
this._onAddressBook(senderId, data, isInbound);
|
this._onAddressBook(senderId, data);
|
||||||
break;
|
break;
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
this._onDisconnect(senderId, data, isInbound);
|
this._onDisconnect(senderId, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ Network.prototype._onMessage = function(enc) {
|
||||||
this._addConnectedCopayer(payload.copayerId);
|
this._addConnectedCopayer(payload.copayerId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.emit('data', sender, payload);
|
this.emit('data', sender, payload, enc.ts);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue