Skip to content

Commit

Permalink
removed purging on new connection, added --purge-interval flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Cazala committed Nov 28, 2017
1 parent 9573a5b commit 069d6ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bin/coin-hive-stratum
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const options = {
diff: argv.diff || defaults.diff,
dynamicPool: argv.hasOwnProperty("dynamic-pool") || defaults.dynamicPool,
maxMinersPerConnection: argv["max-miners-per-connection"] || defaults.maxMinersPerConnection,
path: argv.path || defaults.path
path: argv.path || defaults.path,
purgeInterval: argv["purge-interval"] || defaults.purgeInterval
};

if (isHTTPS) {
Expand Down
1 change: 1 addition & 0 deletions config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
diff: null,
dynamicPool: false,
maxMinersPerConnection: 100,
purgeInterval: 30000,
donations: [
{
address: "46WNbmwXpYxiBpkbHjAgjC65cyzAxtaaBQjcGpAZquhBKw2r8NtPQniEgMJcwFMCZzSBrEJtmPsTR54MoGBDbjTi2W1XmgM",
Expand Down
10 changes: 2 additions & 8 deletions src/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Options = {
cert: Buffer;
path: string;
server: http.Server | https.Server;
purgeInterval: number;
};

class Proxy {
Expand Down Expand Up @@ -62,7 +63,7 @@ class Proxy {
this.cert = options.cert;
this.path = options.path;
this.server = options.server;
this.purgeInterval = setInterval(() => this.purge(), 30 * 1000);
this.purgeInterval = options.purgeInterval > 0 ? setInterval(() => this.purge(), options.purgeInterval) : null;
}

listen(port: number): void {
Expand Down Expand Up @@ -162,13 +163,6 @@ class Proxy {
connections.push(connection);
return connection;
}
while (availableConnections.length > 1) {
const unusedConnection = availableConnections.pop();
this.connections[connectionId] = this.connections[connectionId].filter(
connection => connection.id !== unusedConnection.id
);
unusedConnection.kill();
}
return availableConnections.pop();
}

Expand Down

0 comments on commit 069d6ac

Please sign in to comment.