Skip to content

Commit

Permalink
fix with prettier: added trailing comma
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko committed Aug 7, 2023
1 parent 3a6a35f commit 222ba04
Show file tree
Hide file tree
Showing 86 changed files with 548 additions and 532 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/lib/base_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ export class BaseProtocol implements IBaseProtocol {
public readonly addLibp2pEventListener: Libp2p["addEventListener"];
public readonly removeLibp2pEventListener: Libp2p["removeEventListener"];

constructor(public multicodec: string, private components: Libp2pComponents) {
constructor(
public multicodec: string,
private components: Libp2pComponents,
) {
this.addLibp2pEventListener = components.events.addEventListener.bind(
components.events
components.events,
);
this.removeLibp2pEventListener = components.events.removeEventListener.bind(
components.events
components.events,
);
}

Expand All @@ -43,13 +46,13 @@ export class BaseProtocol implements IBaseProtocol {
const { peer } = await selectPeerForProtocol(
this.peerStore,
[this.multicodec],
peerId
peerId,
);
return peer;
}
protected async newStream(peer: Peer): Promise<Stream> {
const connections = this.components.connectionManager.getConnections(
peer.id
peer.id,
);
const connection = selectConnection(connections);
if (!connection) {
Expand Down
44 changes: 22 additions & 22 deletions packages/core/src/lib/connection_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export class ConnectionManager
libp2p: Libp2p,
keepAliveOptions: KeepAliveOptions,
relay?: IRelay,
options?: ConnectionManagerOptions
options?: ConnectionManagerOptions,
): ConnectionManager {
let instance = ConnectionManager.instances.get(peerId);
if (!instance) {
instance = new ConnectionManager(
libp2p,
keepAliveOptions,
relay,
options
options,
);
ConnectionManager.instances.set(peerId, instance);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ export class ConnectionManager
libp2p: Libp2p,
keepAliveOptions: KeepAliveOptions,
relay?: IRelay,
options?: Partial<ConnectionManagerOptions>
options?: Partial<ConnectionManagerOptions>,
) {
super();
this.libp2p = libp2p;
Expand All @@ -126,7 +126,7 @@ export class ConnectionManager
// which means that before the ConnectionManager is initialized, some peers may have been discovered
// we will dial the peers in peerStore ONCE before we start to listen to the `peer:discovery` events within the ConnectionManager
this.dialPeerStorePeers().catch((error) =>
log(`Unexpected error while dialing peer store peers`, error)
log(`Unexpected error while dialing peer store peers`, error),
);
}

Expand Down Expand Up @@ -159,15 +159,15 @@ export class ConnectionManager
this.keepAliveManager.stopAll();
this.libp2p.removeEventListener(
"peer:connect",
this.onEventHandlers["peer:connect"]
this.onEventHandlers["peer:connect"],
);
this.libp2p.removeEventListener(
"peer:disconnect",
this.onEventHandlers["peer:disconnect"]
this.onEventHandlers["peer:disconnect"],
);
this.libp2p.removeEventListener(
"peer:discovery",
this.onEventHandlers["peer:discovery"]
this.onEventHandlers["peer:discovery"],
);
}

Expand Down Expand Up @@ -198,7 +198,7 @@ export class ConnectionManager
log(
`Error dialing peer ${peerId.toString()} - ${
(error as any).message

Check warning on line 200 in packages/core/src/lib/connection_manager.ts

View workflow job for this annotation

GitHub Actions / proto

Unexpected any. Specify a different type

Check warning on line 200 in packages/core/src/lib/connection_manager.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type
}`
}`,
);
}
this.dialErrorsForPeer.set(peerId.toString(), error);
Expand All @@ -225,14 +225,14 @@ export class ConnectionManager
}

log(
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`,
);

this.dialErrorsForPeer.delete(peerId.toString());
await this.libp2p.peerStore.delete(peerId);
} catch (error) {
throw new Error(
`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`
`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`,
);
}
}
Expand All @@ -245,7 +245,7 @@ export class ConnectionManager
log(`Dropped connection with peer ${peerId.toString()}`);
} catch (error) {
log(
`Error dropping connection with peer ${peerId.toString()} - ${error}`
`Error dropping connection with peer ${peerId.toString()} - ${error}`,
);
}
}
Expand All @@ -266,14 +266,14 @@ export class ConnectionManager
private startPeerDiscoveryListener(): void {
this.libp2p.addEventListener(
"peer:discovery",
this.onEventHandlers["peer:discovery"]
this.onEventHandlers["peer:discovery"],
);
}

private startPeerConnectionListener(): void {
this.libp2p.addEventListener(
"peer:connect",
this.onEventHandlers["peer:connect"]
this.onEventHandlers["peer:connect"],
);
}

Expand All @@ -292,7 +292,7 @@ export class ConnectionManager
*/
this.libp2p.addEventListener(
"peer:disconnect",
this.onEventHandlers["peer:disconnect"]
this.onEventHandlers["peer:disconnect"],
);
}

Expand All @@ -315,7 +315,7 @@ export class ConnectionManager
const { id: peerId } = evt.detail;

const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(
Tags.BOOTSTRAP
Tags.BOOTSTRAP,
);

this.dispatchEvent(
Expand All @@ -325,8 +325,8 @@ export class ConnectionManager
: EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE,
{
detail: peerId,
}
)
},
),
);

try {
Expand All @@ -343,7 +343,7 @@ export class ConnectionManager
this.keepAliveManager.start(peerId, this.libp2p.services.ping);

const isBootstrap = (await this.getTagNamesForPeer(peerId)).includes(
Tags.BOOTSTRAP
Tags.BOOTSTRAP,
);

if (isBootstrap) {
Expand All @@ -362,8 +362,8 @@ export class ConnectionManager
EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP,
{
detail: peerId,
}
)
},
),
);
}
} else {
Expand All @@ -372,8 +372,8 @@ export class ConnectionManager
EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE,
{
detail: peerId,
}
)
},
),
);
}
})();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/filter/filter_rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class FilterSubscribeRpc {

static createSubscribeRequest(
pubsubTopic: string,
contentTopics: string[]
contentTopics: string[],
): FilterSubscribeRpc {
return new FilterSubscribeRpc({
requestId: uuid(),
Expand All @@ -48,7 +48,7 @@ export class FilterSubscribeRpc {

static createUnsubscribeRequest(
pubsubTopic: string,
contentTopics: string[]
contentTopics: string[],
): FilterSubscribeRpc {
return new FilterSubscribeRpc({
requestId: uuid(),
Expand Down
Loading

0 comments on commit 222ba04

Please sign in to comment.