From 30fe22d5cc857519e7973b15ef3775c867924dba Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 2 Dec 2020 16:30:59 +0100 Subject: [PATCH] chore: add interface constructors --- src/stream-muxer/types.ts | 7 +++++++ src/transport/types.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/src/stream-muxer/types.ts b/src/stream-muxer/types.ts index 747dc1ea1..d28f5fb43 100644 --- a/src/stream-muxer/types.ts +++ b/src/stream-muxer/types.ts @@ -2,6 +2,7 @@ * A libp2p stream muxer */ export interface Muxer { + new (options: MuxerOptions): Muxer; multicodec: string; readonly streams: Array; /** @@ -21,6 +22,12 @@ export interface Muxer { onStreamEnd (stream: MuxedStream): void; } +export type MuxerOptions = { + onStream: (stream: MuxedStream) => void; + onStreamEnd: (stream: MuxedStream) => void; + maxMsgSize?: number; +} + export type MuxedTimeline = { open: number; close?: number; diff --git a/src/transport/types.ts b/src/transport/types.ts index c04ea05f5..f630a320d 100644 --- a/src/transport/types.ts +++ b/src/transport/types.ts @@ -6,6 +6,7 @@ import Connection from '../connection/connection' * A libp2p transport is understood as something that offers a dial and listen interface to establish connections. */ export interface Transport { + new (upgrader: Upgrader, ...others: any): Transport; /** * Dial a given multiaddr. */