Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 99c6643

Browse files
Reverted some unnecessary changes.
1 parent 98cad20 commit 99c6643

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/server/server.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ class CacheServer {
2020
this._port = consts.DEFAULT_PORT;
2121

2222
this._server = null;
23-
this._mirrorConfig = options.mirror ? [].concat(options.mirror) : [];
2423
this._mirrors = [];
2524

25+
if(options.mirror) {
26+
options.mirror = [].concat(options.mirror);
27+
this._mirrors = options.mirror.map(m => new TransactionMirror(m, cache));
28+
}
29+
2630
this.allowIpv6 = options.allowIpv6;
2731
this._errCallback = null;
2832
}
@@ -83,11 +87,10 @@ class CacheServer {
8387
const cmdProc = new CommandProcessor(this.cache);
8488
const streamProc = new ClientStreamProcessor({clientAddress: `${socket.remoteAddress}:${socket.remotePort}`});
8589

86-
if(this._mirrors.length > 0) {
90+
const mirrors = this._mirrors;
91+
if(mirrors.length > 0) {
8792
cmdProc.on('onTransactionEnd', (trx) => {
88-
this._mirrors.forEach(m => {
89-
m.queueTransaction(trx);
90-
});
93+
mirrors.forEach(m => m.queueTransaction(trx));
9194
});
9295
}
9396

@@ -111,10 +114,6 @@ class CacheServer {
111114
}
112115

113116
if (this._errCallback && typeof(this._errCallback === 'function')) { this._errCallback(err); }
114-
}).on('listening', () => {
115-
this._mirrors = this._mirrorConfig
116-
.filter(m => m && m.port && m.host)
117-
.map(m => new TransactionMirror(m, this.cache));
118117
});
119118

120119
return new Promise(resolve => {

0 commit comments

Comments
 (0)