Skip to content
Snippets Groups Projects
Commit ab8b492e authored by Gilles Filippini's avatar Gilles Filippini
Browse files

fix(sync): when called with --only-peers

When 'sync' is called with option '--only-peers', the path to function
'RemoteSynchronizer.getPeers()' is not the same as the default.

In this case we need to ensure that 'init()' was properly called and
proceed without a watcher.
parent d01f2505
No related branches found
No related tags found
2 merge requests!1385fix(sync): when called with --only-peers,!1384fix(sync): when called with --only-peers
...@@ -382,16 +382,23 @@ export class RemoteSynchronizer extends AbstractSynchronizer { ...@@ -382,16 +382,23 @@ export class RemoteSynchronizer extends AbstractSynchronizer {
} }
async syncPeers(fullSync: boolean, to?: number): Promise<void> { async syncPeers(fullSync: boolean, to?: number): Promise<void> {
if (!this.node) {
await this.init();
}
const peers = await this.node.getPeers(); const peers = await this.node.getPeers();
for (let i = 0; i < peers.length; i++) { for (let i = 0; i < peers.length; i++) {
const peer = PeerDTO.fromJSONObject(peers[i]); const peer = PeerDTO.fromJSONObject(peers[i]);
this.watcher.writeStatus("Peer " + peer.pubkey); if (this.watcher) {
this.watcher.peersPercent(Math.ceil((i / peers.length) * 100)); this.watcher.writeStatus("Peer " + peer.pubkey);
this.watcher.peersPercent(Math.ceil((i / peers.length) * 100));
}
try { try {
await this.PeeringService.submitP(DBPeer.fromPeerDTO(peer)); await this.PeeringService.submitP(DBPeer.fromPeerDTO(peer));
} catch (e) {} } catch (e) {}
} }
this.watcher.peersPercent(100); if (this.watcher) {
this.watcher.peersPercent(100);
}
} }
async syncSandbox(): Promise<void> { async syncSandbox(): Promise<void> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment