Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit 4e44e1f

Browse files
feat(server): remove agingset
1 parent c78899f commit 4e44e1f

File tree

4 files changed

+1
-80
lines changed

4 files changed

+1
-80
lines changed

src/pool.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as IlpPacket from 'ilp-packet'
33
import { Reader } from 'oer-utils'
44
import { Connection, BuildConnectionOpts } from './connection'
55
import * as cryptoHelper from './crypto'
6-
import { AgingSet } from './util/aging-set'
76

87
const log = createLogger('ilp-protocol-stream:Pool')
98
const CLOSED_CONNECTION_CYCLE = 10 * 60 * 1000 // 10 minutes
@@ -20,8 +19,6 @@ export class ServerConnectionPool {
2019
private onConnection: ConnectionEvent
2120
private activeConnections: { [id: string]: Connection }
2221
private pendingConnections: { [id: string]: Promise<Connection> }
23-
// Use an `AgingSet` so that the connection IDs stored don't accumulate indefinitely.
24-
private closedConnections: AgingSet = new AgingSet(CLOSED_CONNECTION_CYCLE)
2522

2623
constructor (
2724
serverSecret: Buffer,
@@ -36,7 +33,6 @@ export class ServerConnectionPool {
3633
}
3734

3835
async close (): Promise<void> {
39-
this.closedConnections.close()
4036
await Promise.all(Object.keys(this.activeConnections)
4137
.map((id: string) => this.activeConnections[id].end()))
4238
}
@@ -45,11 +41,6 @@ export class ServerConnectionPool {
4541
id: string,
4642
prepare: IlpPacket.IlpPrepare
4743
): Promise<Connection> {
48-
if (this.closedConnections.has(id)) {
49-
log.debug('got packet for connection that was already closed: %s', id)
50-
throw new Error('connection already closed')
51-
}
52-
5344
const activeConnection = this.activeConnections[id]
5445
if (activeConnection) return Promise.resolve(activeConnection)
5546
const pendingConnection = this.pendingConnections[id]
@@ -107,7 +98,6 @@ export class ServerConnectionPool {
10798
conn.once('close', () => {
10899
delete this.pendingConnections[id]
109100
delete this.activeConnections[id]
110-
this.closedConnections.add(id)
111101
})
112102
return conn
113103
})()

src/util/aging-set.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ describe('Server', function () {
307307
it('should reject packets for connections that have already been closed', async function () {
308308
await this.serverConn.destroy()
309309

310-
await assert.isRejected(createConnection({
310+
await assert.isFulfilled(createConnection({
311311
plugin: this.clientPlugin,
312312
sharedSecret: this.sharedSecret,
313313
destinationAccount: this.destinationAccount

test/util/aging-set.test.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)