adding timeout
This commit is contained in:
parent
529ab11481
commit
e822d57905
3 changed files with 14 additions and 3 deletions
|
|
@ -103,6 +103,7 @@ var defaultConfig = {
|
||||||
totalCopayers: 3,
|
totalCopayers: 3,
|
||||||
spendUnconfirmed: 1,
|
spendUnconfirmed: 1,
|
||||||
verbose: 1,
|
verbose: 1,
|
||||||
|
reconnectDelay: 5000,
|
||||||
},
|
},
|
||||||
|
|
||||||
// blockchain service API config
|
// blockchain service API config
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ function Wallet(opts) {
|
||||||
//required params
|
//required params
|
||||||
['storage', 'network', 'blockchain',
|
['storage', 'network', 'blockchain',
|
||||||
'requiredCopayers', 'totalCopayers', 'spendUnconfirmed',
|
'requiredCopayers', 'totalCopayers', 'spendUnconfirmed',
|
||||||
'publicKeyRing', 'txProposals', 'privateKey', 'version'
|
'publicKeyRing', 'txProposals', 'privateKey', 'version',
|
||||||
|
'reconnectDelay'
|
||||||
].forEach(function(k) {
|
].forEach(function(k) {
|
||||||
if (typeof opts[k] === 'undefined')
|
if (typeof opts[k] === 'undefined')
|
||||||
throw new Error('missing required option for Wallet: ' + k);
|
throw new Error('missing required option for Wallet: ' + k);
|
||||||
|
|
@ -247,7 +248,7 @@ Wallet.prototype.netStart = function() {
|
||||||
console.log('[EMIT publicKeyRingUpdated:]'); //TODO
|
console.log('[EMIT publicKeyRingUpdated:]'); //TODO
|
||||||
self.emit('publicKeyRingUpdated', true);
|
self.emit('publicKeyRingUpdated', true);
|
||||||
console.log('[CONNECT:]'); //TODO
|
console.log('[CONNECT:]'); //TODO
|
||||||
self.connectToAll();
|
self.scheduleConnect();
|
||||||
console.log('[EMIT TxProposal]'); //TODO
|
console.log('[EMIT TxProposal]'); //TODO
|
||||||
self.emit('txProposalsUpdated');
|
self.emit('txProposalsUpdated');
|
||||||
self.store();
|
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() {
|
Wallet.prototype.getOnlinePeerIDs = function() {
|
||||||
return this.network.getOnlinePeerIDs();
|
return this.network.getOnlinePeerIDs();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ WalletFactory.prototype.create = function(opts) {
|
||||||
opts.verbose = this.verbose;
|
opts.verbose = this.verbose;
|
||||||
|
|
||||||
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
|
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
|
||||||
|
opts.reconnectDelay = opts.reconnectDelay || this.walletDefaults.reconnectDelay;
|
||||||
opts.requiredCopayers = requiredCopayers;
|
opts.requiredCopayers = requiredCopayers;
|
||||||
opts.totalCopayers = totalCopayers;
|
opts.totalCopayers = totalCopayers;
|
||||||
opts.version = opts.version || this.version;
|
opts.version = opts.version || this.version;
|
||||||
|
|
@ -146,7 +147,6 @@ WalletFactory.prototype.open = function(walletId, opts) {
|
||||||
this.storage._setPassphrase(opts.passphrase);
|
this.storage._setPassphrase(opts.passphrase);
|
||||||
|
|
||||||
var w = this.read(walletId);
|
var w = this.read(walletId);
|
||||||
|
|
||||||
if (w) {
|
if (w) {
|
||||||
this._checkVersion(w.version);
|
this._checkVersion(w.version);
|
||||||
w.store();
|
w.store();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue