2024-01-15 16:12:01 -08:00
|
|
|
import type { PeerId } from "@libp2p/interface";
|
|
|
|
|
import type { PeerStore } from "@libp2p/interface";
|
|
|
|
|
import type { ConnectionManager } from "@libp2p/interface-internal";
|
2022-12-05 17:00:24 +11:00
|
|
|
|
2022-12-13 12:31:27 +11:00
|
|
|
import { IEnr } from "./enr.js";
|
2024-03-13 19:33:50 +05:30
|
|
|
import { IBaseProtocolCore, ProtocolResult } from "./protocols.js";
|
2022-12-05 17:00:24 +11:00
|
|
|
|
2024-03-11 18:50:34 +05:30
|
|
|
export interface IPeerExchange extends IBaseProtocolCore {
|
2024-03-13 19:33:50 +05:30
|
|
|
query(params: PeerExchangeQueryParams): Promise<PeerExchangeResult>;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
|
|
|
|
|
2024-03-13 19:33:50 +05:30
|
|
|
export type PeerExchangeResult = ProtocolResult<"peerInfos", PeerInfo[]>;
|
|
|
|
|
|
2022-12-05 17:00:24 +11:00
|
|
|
export interface PeerExchangeQueryParams {
|
|
|
|
|
numPeers: number;
|
2024-01-11 17:25:47 +05:30
|
|
|
peerId: PeerId;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PeerExchangeResponse {
|
|
|
|
|
peerInfos: PeerInfo[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PeerInfo {
|
2022-12-13 12:31:27 +11:00
|
|
|
ENR?: IEnr;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PeerExchangeComponents {
|
|
|
|
|
connectionManager: ConnectionManager;
|
|
|
|
|
peerStore: PeerStore;
|
|
|
|
|
}
|