Skip to content
Snippets Groups Projects
Commit f682ddef authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] #1326 Spread connection error message

parent eaf88870
Branches
Tags
No related merge requests found
...@@ -58,6 +58,7 @@ export class Synchroniser extends stream.Duplex { ...@@ -58,6 +58,7 @@ export class Synchroniser extends stream.Duplex {
this.watcher.onEvent('wantToLoad', (data) => this.push({ p2pData: { name: 'wantToLoad', data }})) 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('beforeReadyNodes', (data) => this.push({ p2pData: { name: 'beforeReadyNodes', data }}))
this.watcher.onEvent('syncFailNoNodeFound', (data) => this.push({ p2pData: { name: 'syncFailNoNodeFound', 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) this.syncStrategy.setWatcher(this.watcher)
......
...@@ -101,6 +101,7 @@ export class RemoteSynchronizer extends AbstractSynchronizer { ...@@ -101,6 +101,7 @@ export class RemoteSynchronizer extends AbstractSynchronizer {
async init(): Promise<void> { async init(): Promise<void> {
const syncApi = await RemoteSynchronizer.getSyncAPI([{ host: this.host, port: this.port }], this.server.conf.pair) const syncApi = await RemoteSynchronizer.getSyncAPI([{ host: this.host, port: this.port }], this.server.conf.pair)
if (!syncApi.api) { if (!syncApi.api) {
this.watcher.syncFailCannotConnectToRemote()
throw Error(DataErrors[DataErrors.CANNOT_CONNECT_TO_REMOTE_FOR_SYNC]) throw Error(DataErrors[DataErrors.CANNOT_CONNECT_TO_REMOTE_FOR_SYNC])
} }
this.currency = syncApi.currency this.currency = syncApi.currency
......
...@@ -32,6 +32,8 @@ export interface Watcher { ...@@ -32,6 +32,8 @@ export interface Watcher {
beforeReadyNodes(p2pCandidates: P2pCandidate[]): void beforeReadyNodes(p2pCandidates: P2pCandidate[]): void
syncFailNoNodeFound(): void syncFailNoNodeFound(): void
syncFailCannotConnectToRemote(): void
} }
export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxChange'|'peersChange' export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxChange'|'peersChange'
...@@ -45,6 +47,7 @@ export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxCha ...@@ -45,6 +47,7 @@ export type EventName = 'downloadChange'|'storageChange'|'appliedChange'|'sbxCha
| 'wantToLoad' | 'wantToLoad'
| 'beforeReadyNodes' | 'beforeReadyNodes'
| 'syncFailNoNodeFound' | 'syncFailNoNodeFound'
| 'syncFailCannotConnectToRemote'
export class EventWatcher extends events.EventEmitter implements Watcher { export class EventWatcher extends events.EventEmitter implements Watcher {
...@@ -142,6 +145,10 @@ export class EventWatcher extends events.EventEmitter implements Watcher { ...@@ -142,6 +145,10 @@ export class EventWatcher extends events.EventEmitter implements Watcher {
syncFailNoNodeFound(): void { syncFailNoNodeFound(): void {
this.emit('syncFailNoNodeFound', {}) this.emit('syncFailNoNodeFound', {})
} }
syncFailCannotConnectToRemote(): void {
this.emit('syncFailCannotConnectToRemote', {})
}
} }
export class MultimeterWatcher implements Watcher { export class MultimeterWatcher implements Watcher {
...@@ -282,6 +289,9 @@ export class MultimeterWatcher implements Watcher { ...@@ -282,6 +289,9 @@ export class MultimeterWatcher implements Watcher {
syncFailNoNodeFound(): void { syncFailNoNodeFound(): void {
} }
syncFailCannotConnectToRemote(): void {
}
} }
export class LoggerWatcher implements Watcher { export class LoggerWatcher implements Watcher {
...@@ -377,4 +387,7 @@ export class LoggerWatcher implements Watcher { ...@@ -377,4 +387,7 @@ export class LoggerWatcher implements Watcher {
syncFailNoNodeFound(): void { syncFailNoNodeFound(): void {
} }
syncFailCannotConnectToRemote(): void {
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment