Skip to content

Commit

Permalink
fix: update interface internal and release as v1 (#2282)
Browse files Browse the repository at this point in the history
Release-As: 1.0.0
  • Loading branch information
achingbrain authored Dec 1, 2023
1 parent 09ee5aa commit e7167fe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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>
}

0 comments on commit e7167fe

Please sign in to comment.