diff --git a/packages/interface-compliance-tests/src/connection/index.ts b/packages/interface-compliance-tests/src/connection/index.ts index 833ca30ba1..604030182d 100644 --- a/packages/interface-compliance-tests/src/connection/index.ts +++ b/packages/interface-compliance-tests/src/connection/index.ts @@ -127,7 +127,7 @@ export default (test: TestSetup): void => { it.skip('should track inbound streams', async () => { // Add an remotely opened stream const stream = stubInterface() - connection.addStream(stream) + // connection.addStream(stream) expect(stream).to.have.property('direction', 'inbound') }) diff --git a/packages/interface-compliance-tests/src/mocks/connection.ts b/packages/interface-compliance-tests/src/mocks/connection.ts index 8c88ba057b..566de6d05c 100644 --- a/packages/interface-compliance-tests/src/mocks/connection.ts +++ b/packages/interface-compliance-tests/src/mocks/connection.ts @@ -94,14 +94,6 @@ class MockConnection implements Connection { return stream } - addStream (stream: Stream): void { - this.streams.push(stream) - } - - removeStream (id: string): void { - this.streams = this.streams.filter(stream => stream.id !== id) - } - async close (options?: AbortOptions): Promise { this.status = 'closing' await Promise.all( @@ -147,7 +139,7 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio muxedStream.sink = stream.sink muxedStream.source = stream.source - connection.addStream(muxedStream) + connection.streams.push(muxedStream) const { handler } = registrar.getHandler(protocol) handler({ connection, stream: muxedStream }) @@ -159,7 +151,7 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio } }, onStreamEnd: (muxedStream) => { - connection.removeStream(muxedStream.id) + connection.streams = connection.streams.filter(stream => stream.id !== muxedStream.id) } }) diff --git a/packages/interface/src/connection/index.ts b/packages/interface/src/connection/index.ts index 6a2100f75d..2bed6736a1 100644 --- a/packages/interface/src/connection/index.ts +++ b/packages/interface/src/connection/index.ts @@ -258,16 +258,6 @@ export interface Connection { */ newStream: (protocols: string | string[], options?: NewStreamOptions) => Promise - /** - * Add a stream to this connection - */ - addStream: (stream: Stream) => void - - /** - * Remove a stream from this connection - */ - removeStream: (id: string) => void - /** * Gracefully close the connection. All queued data will be written to the * underlying transport. diff --git a/packages/libp2p/src/connection/index.ts b/packages/libp2p/src/connection/index.ts index 53b1a704b3..8509b8d70a 100644 --- a/packages/libp2p/src/connection/index.ts +++ b/packages/libp2p/src/connection/index.ts @@ -138,20 +138,6 @@ export class ConnectionImpl implements Connection { return stream } - /** - * Add a stream when it is opened to the registry - */ - addStream (stream: Stream): void { - stream.direction = 'inbound' - } - - /** - * Remove stream registry after it is closed - */ - removeStream (id: string): void { - - } - /** * Close the connection */ diff --git a/packages/libp2p/src/upgrader.ts b/packages/libp2p/src/upgrader.ts index f77dcf6319..adf079b49f 100644 --- a/packages/libp2p/src/upgrader.ts +++ b/packages/libp2p/src/upgrader.ts @@ -415,7 +415,6 @@ export class DefaultUpgrader implements Upgrader { protocols: [protocol] }) - connection.addStream(muxedStream) this.components.metrics?.trackProtocolStream(muxedStream, connection) this._onStream({ connection, stream: muxedStream, protocol }) @@ -427,10 +426,6 @@ export class DefaultUpgrader implements Upgrader { await muxedStream.close() } }) - }, - // Run anytime a stream closes - onStreamEnd: muxedStream => { - connection?.removeStream(muxedStream.id) } }) diff --git a/packages/libp2p/test/connection/compliance.spec.ts b/packages/libp2p/test/connection/compliance.spec.ts index ca216acd5d..41059425b7 100644 --- a/packages/libp2p/test/connection/compliance.spec.ts +++ b/packages/libp2p/test/connection/compliance.spec.ts @@ -35,7 +35,6 @@ describe('connection compliance', () => { ...pair(), close: async () => { void stream.sink(async function * () {}()) - connection.removeStream(stream.id) openStreams = openStreams.filter(s => s.id !== id) }, closeRead: async () => {},