diff --git a/app/modules/crawler/lib/sync.ts b/app/modules/crawler/lib/sync.ts index 9b28381c932cb01ffe51a445f508d383f980068c..69f6f21b86547f8229385b59140341c4b41f97c5 100644 --- a/app/modules/crawler/lib/sync.ts +++ b/app/modules/crawler/lib/sync.ts @@ -58,6 +58,7 @@ export class Synchroniser extends stream.Duplex { this.watcher.onEvent('wantToLoad', (data) => this.push({ p2pData: { name: 'wantToLoad', data }})) this.watcher.onEvent('beforeReadyNodes', (data) => this.push({ p2pData: { name: 'beforeReadyNodes', data }})) this.watcher.onEvent('syncFailNoNodeFound', (data) => this.push({ p2pData: { name: 'syncFailNoNodeFound', data }})) + this.watcher.onEvent('syncFailCannotConnectToRemote', (data) => this.push({ p2pData: { name: 'syncFailCannotConnectToRemote', data }})) this.syncStrategy.setWatcher(this.watcher) diff --git a/app/modules/crawler/lib/sync/RemoteSynchronizer.ts b/app/modules/crawler/lib/sync/RemoteSynchronizer.ts index 7916d0c0157c813aa931883c49733bfc8b36ebc5..e18e1f4fad432c7ecacf5a84a1d5cf8a1703a8ba 100644 --- a/app/modules/crawler/lib/sync/RemoteSynchronizer.ts +++ b/app/modules/crawler/lib/sync/RemoteSynchronizer.ts @@ -101,6 +101,7 @@ export class RemoteSynchronizer extends AbstractSynchronizer { async init(): Promise<void> { const syncApi = await RemoteSynchronizer.getSyncAPI([{ host: this.host, port: this.port }], this.server.conf.pair) if (!syncApi.api) { + this.watcher.syncFailCannotConnectToRemote() throw Error(DataErrors[DataErrors.CANNOT_CONNECT_TO_REMOTE_FOR_SYNC]) } this.currency = syncApi.currency diff --git a/app/modules/crawler/lib/sync/Watcher.ts b/app/modules/crawler/lib/sync/Watcher.ts index 3bc8cb0df67627821c178784022ac0607933275f..3679f8f877c2a56a115efe176323aaeb459d42a1 100644 --- a/app/modules/crawler/lib/sync/Watcher.ts +++ b/app/modules/crawler/lib/sync/Watcher.ts @@ -32,6 +32,8 @@ export interface Watcher { beforeReadyNodes(p2pCandidates: P2pCandidate[]): void syncFailNoNodeFound(): void + + syncFailCannotConnectToRemote(): void } export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxChange'|'peersChange' @@ -45,6 +47,7 @@ export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxCha | 'wantToLoad' | 'beforeReadyNodes' | 'syncFailNoNodeFound' + | 'syncFailCannotConnectToRemote' export class EventWatcher extends events.EventEmitter implements Watcher { @@ -142,6 +145,10 @@ export class EventWatcher extends events.EventEmitter implements Watcher { syncFailNoNodeFound(): void { this.emit('syncFailNoNodeFound', {}) } + + syncFailCannotConnectToRemote(): void { + this.emit('syncFailCannotConnectToRemote', {}) + } } export class MultimeterWatcher implements Watcher { @@ -282,6 +289,9 @@ export class MultimeterWatcher implements Watcher { syncFailNoNodeFound(): void { } + syncFailCannotConnectToRemote(): void { + } + } export class LoggerWatcher implements Watcher { @@ -377,4 +387,7 @@ export class LoggerWatcher implements Watcher { syncFailNoNodeFound(): void { } + syncFailCannotConnectToRemote(): void { + } + }