Skip to content

fix: update interface internal and release as v1 #2282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/interface-internal/src/registrar/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import type { Connection, Stream, Topology } from '@libp2p/interface'

export interface IncomingStreamData {
/**
* The stream that has been opened
*/
stream: Stream

/**
* The connection that the stream was opened on
*/
connection: Connection
}

Expand Down Expand Up @@ -29,7 +36,14 @@ export interface StreamHandlerOptions {
}

export interface StreamHandlerRecord {
/**
* The handler that was registered to handle streams opened on the protocol
*/
handler: StreamHandler

/**
* The options that were used to register the stream handler
*/
options: StreamHandlerOptions
}

Expand Down
38 changes: 38 additions & 0 deletions packages/interface-internal/src/transport-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,51 @@ import type { Connection, Listener, Transport } from '@libp2p/interface'
import type { Multiaddr } from '@multiformats/multiaddr'

export interface TransportManager {
/**
* Add a transport to the transport manager
*/
add(transport: Transport): void

/**
* Dial a multiaddr. Connections returned by this method will not be tracked
* by the connection manager so can cause memory leaks. If you need to dial
* a multiaddr, you may want to call openConnection on the connection manager
* instead.
*/
dial(ma: Multiaddr, options?: any): Promise<Connection>

/**
* Return all addresses currently being listened on
*/
getAddrs(): Multiaddr[]

/**
* Return all registered transports
*/
getTransports(): Transport[]

/**
* Return all listeners
*/
getListeners(): Listener[]

/**
* Get the transport for a given multiaddr, if one has been configured
*/
transportForMultiaddr(ma: Multiaddr): Transport | undefined

/**
* Listen on the passed multiaddrs
*/
listen(addrs: Multiaddr[]): Promise<void>

/**
* Remove a previously configured transport
*/
remove(key: string): Promise<void>

/**
* Remove all transports
*/
removeAll(): Promise<void>
}