mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-22 09:08:19 +00:00
fix: build
This commit is contained in:
parent
3384b875a9
commit
557ee96b52
@ -8,6 +8,7 @@ import type {
|
|||||||
import { Logger, pubsubTopicsToShardInfo } from "@waku/utils";
|
import { Logger, pubsubTopicsToShardInfo } from "@waku/utils";
|
||||||
import {
|
import {
|
||||||
getConnectedPeersForProtocolAndShard,
|
getConnectedPeersForProtocolAndShard,
|
||||||
|
getPeersForProtocol,
|
||||||
sortPeersByLatency
|
sortPeersByLatency
|
||||||
} from "@waku/utils/libp2p";
|
} from "@waku/utils/libp2p";
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ export class BaseProtocol implements IBaseProtocolCore {
|
|||||||
|
|
||||||
protected constructor(
|
protected constructor(
|
||||||
public multicodec: string,
|
public multicodec: string,
|
||||||
private components: Libp2pComponents,
|
protected components: Libp2pComponents,
|
||||||
private log: Logger,
|
private log: Logger,
|
||||||
public readonly pubsubTopics: PubsubTopic[]
|
public readonly pubsubTopics: PubsubTopic[]
|
||||||
) {
|
) {
|
||||||
@ -55,21 +56,21 @@ export class BaseProtocol implements IBaseProtocolCore {
|
|||||||
* the class protocol. Waku may or may not be currently connected to these
|
* the class protocol. Waku may or may not be currently connected to these
|
||||||
* peers.
|
* peers.
|
||||||
*/
|
*/
|
||||||
// public async allPeers(): Promise<Peer[]> {
|
public async allPeers(): Promise<Peer[]> {
|
||||||
// return getPeersForProtocol(this.peerStore, [this.multicodec]);
|
return getPeersForProtocol(this.components.peerStore, [this.multicodec]);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public async connectedPeers(): Promise<Peer[]> {
|
public async connectedPeers(): Promise<Peer[]> {
|
||||||
// const peers = await this.allPeers();
|
const peers = await this.allPeers();
|
||||||
// return peers.filter((peer) => {
|
return peers.filter((peer) => {
|
||||||
// const connections = this.components.connectionManager.getConnections(
|
const connections = this.components.connectionManager.getConnections(
|
||||||
// peer.id
|
peer.id
|
||||||
// );
|
);
|
||||||
// return connections.some((c) =>
|
return connections.some((c) =>
|
||||||
// c.streams.some((s) => s.protocol === this.multicodec)
|
c.streams.some((s) => s.protocol === this.multicodec)
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a list of connected peers that support the protocol. The list is sorted by latency.
|
* Retrieves a list of connected peers that support the protocol. The list is sorted by latency.
|
||||||
|
@ -45,7 +45,7 @@ class Metadata extends BaseProtocol implements IMetadata {
|
|||||||
pubsubTopicsToShardInfo(this.pubsubTopics)
|
pubsubTopicsToShardInfo(this.pubsubTopics)
|
||||||
);
|
);
|
||||||
|
|
||||||
const peer = await this.peerStore.get(peerId);
|
const peer = await this.libp2pComponents.peerStore.get(peerId);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
return {
|
return {
|
||||||
shardInfo: null,
|
shardInfo: null,
|
||||||
|
@ -47,7 +47,7 @@ export class WakuPeerExchange extends BaseProtocol implements IPeerExchange {
|
|||||||
numPeers: BigInt(numPeers)
|
numPeers: BigInt(numPeers)
|
||||||
});
|
});
|
||||||
|
|
||||||
const peer = await this.peerStore.get(peerId);
|
const peer = await this.components.peerStore.get(peerId);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
return {
|
return {
|
||||||
peerInfos: null,
|
peerInfos: null,
|
||||||
|
@ -16,6 +16,8 @@ export enum Protocols {
|
|||||||
|
|
||||||
export type IBaseProtocolCore = {
|
export type IBaseProtocolCore = {
|
||||||
multicodec: string;
|
multicodec: string;
|
||||||
|
allPeers: () => Promise<Peer[]>;
|
||||||
|
connectedPeers: () => Promise<Peer[]>;
|
||||||
addLibp2pEventListener: Libp2p["addEventListener"];
|
addLibp2pEventListener: Libp2p["addEventListener"];
|
||||||
removeLibp2pEventListener: Libp2p["removeEventListener"];
|
removeLibp2pEventListener: Libp2p["removeEventListener"];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user