libp2p
Version:
JavaScript implementation of libp2p, a modular peer to peer network stack
28 lines • 1.08 kB
TypeScript
import type { Metrics, PeerId, PeerInfo, PeerRouting, PeerStore, RoutingOptions } from '@libp2p/interface';
import type { ComponentLogger } from '@libp2p/logger';
export interface PeerRoutingInit {
routers?: PeerRouting[];
}
export interface DefaultPeerRoutingComponents {
peerId: PeerId;
peerStore: PeerStore;
logger: ComponentLogger;
metrics?: Metrics;
}
export declare class DefaultPeerRouting implements PeerRouting {
private readonly log;
private readonly peerId;
private readonly peerStore;
private readonly routers;
constructor(components: DefaultPeerRoutingComponents, init?: PeerRoutingInit);
readonly [Symbol.toStringTag] = "@libp2p/peer-routing";
/**
* Iterates over all peer routers in parallel to find the given peer
*/
findPeer(id: PeerId, options?: RoutingOptions): Promise<PeerInfo>;
/**
* Attempt to find the closest peers on the network to the given key
*/
getClosestPeers(key: Uint8Array, options?: RoutingOptions): AsyncGenerator<PeerInfo>;
}
//# sourceMappingURL=peer-routing.d.ts.map