Commit f682ddef authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] #1326 Spread connection error message

parent eaf88870
......@@ -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)
......
......@@ -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
......
......@@ -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 {
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment