mirror of https://github.com/BTCPrivate/copay.git
adding timeout
This commit is contained in:
parent
529ab11481
commit
e822d57905
|
@ -103,6 +103,7 @@ var defaultConfig = {
|
|||
totalCopayers: 3,
|
||||
spendUnconfirmed: 1,
|
||||
verbose: 1,
|
||||
reconnectDelay: 5000,
|
||||
},
|
||||
|
||||
// blockchain service API config
|
||||
|
|
|
@ -19,7 +19,8 @@ function Wallet(opts) {
|
|||
//required params
|
||||
['storage', 'network', 'blockchain',
|
||||
'requiredCopayers', 'totalCopayers', 'spendUnconfirmed',
|
||||
'publicKeyRing', 'txProposals', 'privateKey', 'version'
|
||||
'publicKeyRing', 'txProposals', 'privateKey', 'version',
|
||||
'reconnectDelay'
|
||||
].forEach(function(k) {
|
||||
if (typeof opts[k] === 'undefined')
|
||||
throw new Error('missing required option for Wallet: ' + k);
|
||||
|
@ -247,7 +248,7 @@ Wallet.prototype.netStart = function() {
|
|||
console.log('[EMIT publicKeyRingUpdated:]'); //TODO
|
||||
self.emit('publicKeyRingUpdated', true);
|
||||
console.log('[CONNECT:]'); //TODO
|
||||
self.connectToAll();
|
||||
self.scheduleConnect();
|
||||
console.log('[EMIT TxProposal]'); //TODO
|
||||
self.emit('txProposalsUpdated');
|
||||
self.store();
|
||||
|
@ -255,6 +256,15 @@ Wallet.prototype.netStart = function() {
|
|||
});
|
||||
};
|
||||
|
||||
Wallet.prototype.scheduleConnect = function() {
|
||||
var self = this;
|
||||
self.connectToAll();
|
||||
setTimeout(function() {
|
||||
self.scheduleConnect();
|
||||
},
|
||||
self.reconnectDelay);
|
||||
}
|
||||
|
||||
Wallet.prototype.getOnlinePeerIDs = function() {
|
||||
return this.network.getOnlinePeerIDs();
|
||||
};
|
||||
|
|
|
@ -115,6 +115,7 @@ WalletFactory.prototype.create = function(opts) {
|
|||
opts.verbose = this.verbose;
|
||||
|
||||
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
|
||||
opts.reconnectDelay = opts.reconnectDelay || this.walletDefaults.reconnectDelay;
|
||||
opts.requiredCopayers = requiredCopayers;
|
||||
opts.totalCopayers = totalCopayers;
|
||||
opts.version = opts.version || this.version;
|
||||
|
@ -146,7 +147,6 @@ WalletFactory.prototype.open = function(walletId, opts) {
|
|||
this.storage._setPassphrase(opts.passphrase);
|
||||
|
||||
var w = this.read(walletId);
|
||||
|
||||
if (w) {
|
||||
this._checkVersion(w.version);
|
||||
w.store();
|
||||
|
|
Loading…
Reference in New Issue