@libp2p/interface
Advanced tools
Comparing version 2.2.0 to 2.2.1-f53f65d18
@@ -8,5 +8,15 @@ import type { Connection, ConnectionLimits, MultiaddrConnection } from '../connection/index.js'; | ||
export interface ListenerEvents { | ||
'connection': CustomEvent<Connection>; | ||
/** | ||
* This event signals to the transport manager that the listening addresses | ||
* have changed and may be emitted at any point and/or multiple times | ||
*/ | ||
'listening': CustomEvent; | ||
/** | ||
* Emitted if listening on an address failed | ||
*/ | ||
'error': CustomEvent<Error>; | ||
/** | ||
* Emitted when the listener has been shut down, has no open connections and | ||
* will no longer accept new connections | ||
*/ | ||
'close': CustomEvent; | ||
@@ -31,5 +41,2 @@ } | ||
export declare const transportSymbol: unique symbol; | ||
export interface ConnectionHandler { | ||
(connection: Connection): void; | ||
} | ||
export interface MultiaddrFilter { | ||
@@ -39,6 +46,13 @@ (multiaddrs: Multiaddr[]): Multiaddr[]; | ||
export interface CreateListenerOptions { | ||
handler?: ConnectionHandler; | ||
/** | ||
* The upgrader turns a MultiaddrConnection into a Connection and notifies | ||
* other libp2p components about a new incoming connection. | ||
*/ | ||
upgrader: Upgrader; | ||
} | ||
export interface DialTransportOptions<DialEvents extends ProgressEvent = ProgressEvent> extends AbortOptions, ProgressOptions<DialEvents> { | ||
/** | ||
* The upgrader turns a MultiaddrConnection into a Connection which should be | ||
* returned by the transport's dial method | ||
*/ | ||
upgrader: Upgrader; | ||
@@ -101,10 +115,11 @@ } | ||
/** | ||
* Upgrades an outbound connection on `transport.dial`. | ||
* Upgrades an outbound connection created by the `dial` method of a transport | ||
*/ | ||
upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>; | ||
/** | ||
* Upgrades an inbound connection on transport listener. | ||
* Upgrades an inbound connection received by a transport listener and | ||
* notifies other libp2p components about the new connection | ||
*/ | ||
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<Connection>; | ||
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@libp2p/interface", | ||
"version": "2.2.0", | ||
"version": "2.2.1-f53f65d18", | ||
"description": "The interface implemented by a libp2p node", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -9,5 +9,17 @@ import type { Connection, ConnectionLimits, MultiaddrConnection } from '../connection/index.js' | ||
export interface ListenerEvents { | ||
'connection': CustomEvent<Connection> | ||
/** | ||
* This event signals to the transport manager that the listening addresses | ||
* have changed and may be emitted at any point and/or multiple times | ||
*/ | ||
'listening': CustomEvent | ||
/** | ||
* Emitted if listening on an address failed | ||
*/ | ||
'error': CustomEvent<Error> | ||
/** | ||
* Emitted when the listener has been shut down, has no open connections and | ||
* will no longer accept new connections | ||
*/ | ||
'close': CustomEvent | ||
@@ -35,8 +47,9 @@ } | ||
export interface ConnectionHandler { (connection: Connection): void } | ||
export interface MultiaddrFilter { (multiaddrs: Multiaddr[]): Multiaddr[] } | ||
export interface CreateListenerOptions { | ||
handler?: ConnectionHandler | ||
/** | ||
* The upgrader turns a MultiaddrConnection into a Connection and notifies | ||
* other libp2p components about a new incoming connection. | ||
*/ | ||
upgrader: Upgrader | ||
@@ -46,2 +59,6 @@ } | ||
export interface DialTransportOptions<DialEvents extends ProgressEvent = ProgressEvent> extends AbortOptions, ProgressOptions<DialEvents> { | ||
/** | ||
* The upgrader turns a MultiaddrConnection into a Connection which should be | ||
* returned by the transport's dial method | ||
*/ | ||
upgrader: Upgrader | ||
@@ -123,3 +140,3 @@ } | ||
/** | ||
* Upgrades an outbound connection on `transport.dial`. | ||
* Upgrades an outbound connection created by the `dial` method of a transport | ||
*/ | ||
@@ -129,5 +146,6 @@ upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection> | ||
/** | ||
* Upgrades an inbound connection on transport listener. | ||
* Upgrades an inbound connection received by a transport listener and | ||
* notifies other libp2p components about the new connection | ||
*/ | ||
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<Connection> | ||
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void> | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
302021
124
7467
1