pubkeyring syncing, w00t
This commit is contained in:
parent
497a93991e
commit
8b6c2df6bd
2 changed files with 18 additions and 4 deletions
|
|
@ -321,7 +321,6 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
this.emit('badMessage', senderId);
|
this.emit('badMessage', senderId);
|
||||||
this.log('badMessage FROM:', senderId);
|
this.log('badMessage FROM:', senderId);
|
||||||
alert('fuck');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ var preconditions = require('preconditions').singleton();
|
||||||
function Network(opts) {
|
function Network(opts) {
|
||||||
var self = this;
|
var self = this;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
this.maxPeers = opts.maxPeers || 12;
|
||||||
this.host = opts.host || 'localhost';
|
this.host = opts.host || 'localhost';
|
||||||
this.port = opts.port || 3001;
|
this.port = opts.port || 3001;
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
|
@ -259,7 +260,7 @@ Network.prototype._addCopayerMap = function(peerId, copayerId) {
|
||||||
if (!this.copayerForPeer[peerId]) {
|
if (!this.copayerForPeer[peerId]) {
|
||||||
if (Object.keys(this.copayerForPeer).length < this.maxPeers) {
|
if (Object.keys(this.copayerForPeer).length < this.maxPeers) {
|
||||||
this.copayerForPeer[peerId] = copayerId;
|
this.copayerForPeer[peerId] = copayerId;
|
||||||
} else {}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -332,12 +333,25 @@ Network.prototype.getPeer = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Network.prototype.getCopayerIds = function() {
|
||||||
|
if (this.allowedCopayerIds) {
|
||||||
|
return Object.keys(this.allowedCopayerIds);
|
||||||
|
} else {
|
||||||
|
var copayerIds = [];
|
||||||
|
for (var peerId in this.copayerForPeer) {
|
||||||
|
copayerIds.push(this.copayerForPeer[peerId]);
|
||||||
|
}
|
||||||
|
return copayerIds;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Network.prototype.send = function(copayerIds, payload, cb) {
|
Network.prototype.send = function(copayerIds, payload, cb) {
|
||||||
preconditions.checkArgument(payload);
|
preconditions.checkArgument(payload);
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!copayerIds) {
|
if (!copayerIds) {
|
||||||
copayerIds = this.connectedCopayers();
|
copayerIds = this.getCopayerIds();
|
||||||
payload.isBroadcast = 1;
|
payload.isBroadcast = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,14 +360,15 @@ Network.prototype.send = function(copayerIds, payload, cb) {
|
||||||
|
|
||||||
var l = copayerIds.length;
|
var l = copayerIds.length;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
console.log('sending ' + JSON.stringify(payload));
|
||||||
copayerIds.forEach(function(copayerId) {
|
copayerIds.forEach(function(copayerId) {
|
||||||
|
console.log('\t to ' + copayerId);
|
||||||
self.iterateNonce();
|
self.iterateNonce();
|
||||||
var opts = {
|
var opts = {
|
||||||
nonce: self.networkNonce
|
nonce: self.networkNonce
|
||||||
};
|
};
|
||||||
var copayerIdBuf = new Buffer(copayerId, 'hex');
|
var copayerIdBuf = new Buffer(copayerId, 'hex');
|
||||||
var message = AuthMessage.encode(copayerIdBuf, self.getKey(), payload, opts);
|
var message = AuthMessage.encode(copayerIdBuf, self.getKey(), payload, opts);
|
||||||
console.log('sending ' + JSON.stringify(payload));
|
|
||||||
self.socket.emit('message', message);
|
self.socket.emit('message', message);
|
||||||
});
|
});
|
||||||
if (typeof cb === 'function') cb();
|
if (typeof cb === 'function') cb();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue