fix p2p connecting

This commit is contained in:
Matias Alejo Garcia 2014-04-18 11:19:39 -03:00
commit ba8a0e83d2
6 changed files with 46 additions and 15 deletions

View file

@ -310,6 +310,22 @@ Wallet.prototype.getAddressesStr = function(onlyMain) {
return ret;
};
Wallet.prototype.addressIsOwn = function(addrStr) {
var addrList = this.getAddressesStr();
var l = addrList.length;
var ret = false;
for(var i=0; i<l; i++) {
if (addrList[i] === addrStr) {
ret = true;
break;
}
}
return ret;
};
Wallet.prototype.getTotalBalance = function(cb) {
this.getBalance(this.getAddressesStr(), function(balance) {
return cb(balance);

View file

@ -44,12 +44,12 @@ WalletFactory.prototype._checkRead = function(walletId) {
s.get(walletId, 'opts') &&
s.get(walletId, 'privateKey')
;
return ret;
return ret?true:false;
};
WalletFactory.prototype.read = function(walletId) {
if (! this._checkRead(walletId))
throw Error('Check read failed');
return false;
var s = this.storage;
var opts = s.get(walletId, 'opts');
@ -175,7 +175,7 @@ WalletFactory.prototype.connectTo = function(peerId, cb) {
self.network.start(function() {
self.network.connectTo(peerId)
self.network.on('walletId', function(walletId) {
console.log('[WalletFactory.js.187]'); //TODO
self.log('Opening walletId:' + walletId);
return cb(self.open(walletId));
});
});