Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
feat: expose dial queue inspection method (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Apr 17, 2023
1 parent 18c5622 commit 973263f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/interface-libp2p/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ export interface LookupFunction {
(key: string): Promise<Uint8Array | null>
}

export type PendingDialStatus = 'queued' | 'active' | 'error' | 'success'

/**
* An item in the dial queue
*/
export interface PendingDial {
/**
* A unique identifier for this dial
*/
id: string

/**
* The current status of the dial
*/
status: PendingDialStatus

/**
* If known, this is the peer id that libp2p expects to be dialling
*/
peerId?: PeerId

/**
* The list of multiaddrs that will be dialled. The returned connection will
* use the first address that succeeds, all other dials part of this pending
* dial will be cancelled.
*/
multiaddrs: Multiaddr[]
}

/**
* Libp2p nodes implement this interface.
*/
Expand Down Expand Up @@ -323,6 +352,19 @@ export interface Libp2p extends Startable, EventEmitter<Libp2pEvents> {
*/
getConnections: (peerId?: PeerId) => Connection[]

/**
* Return the list of dials currently in progress or queued to start
*
* @example
*
* ```js
* for (const pendingDial of libp2p.getDialQueue()) {
* console.log(pendingDial)
* }
* ```
*/
getDialQueue: () => PendingDial[]

/**
* Return a list of all peers we currently have a connection open to
*/
Expand Down

0 comments on commit 973263f

Please sign in to comment.