Skip to content

Commit

Permalink
chore: rename local-discovery to local-peer-cache-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Feb 27, 2024
1 parent 7af6b71 commit e7993ea
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ test-results
playwright-report
example
allure-results
packages/local-discovery/mock_local_storage
packages/local-peer-cache-discovery/mock_local_storage
115 changes: 65 additions & 50 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"packages/relay",
"packages/peer-exchange",
"packages/dns-discovery",
"packages/local-discovery",
"packages/local-peer-cache-discovery",
"packages/message-encryption",
"packages/sdk",
"packages/tests",
Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/src/connection_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Peer, PeerId, TypedEventEmitter } from "@libp2p/interface";
export enum Tags {
BOOTSTRAP = "bootstrap",
PEER_EXCHANGE = "peer-exchange",
LOCAL = "local"
LOCAL = "local-peer-cache"
}

export interface ConnectionManagerOptions {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@waku/local-discovery",
"name": "@waku/local-peer-cache-discovery",
"version": "0.0.1",
"description": "Local Discovery keeps records of healthy peers in the browser's local storage for quicker bootstrapping.",
"description": "Local Peer Cache keeps records of healthy peers in the browser's local storage for quicker bootstrapping.",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
Expand All @@ -12,7 +12,7 @@
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/local-discovery#readme",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/local-peer-cache-discovery#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getWsMultiaddrFromMultiaddrs, Logger } from "@waku/utils";

const log = new Logger("peer-exchange-discovery");

type LocalStorageDiscoveryOptions = {
type LocalPeerCacheDiscoveryOptions = {
tagName?: string;
tagValue?: number;
tagTTL?: number;
Expand All @@ -28,7 +28,7 @@ export const DEFAULT_LOCAL_TAG_NAME = Tags.LOCAL;
const DEFAULT_LOCAL_TAG_VALUE = 50;
const DEFAULT_LOCAL_TAG_TTL = 100_000_000;

export class LocalStorageDiscovery
export class LocalPeerCacheDiscovery
extends TypedEventEmitter<PeerDiscoveryEvents>
implements PeerDiscovery, Startable
{
Expand All @@ -37,15 +37,15 @@ export class LocalStorageDiscovery

constructor(
private readonly components: Libp2pComponents,
private readonly options?: LocalStorageDiscoveryOptions
private readonly options?: LocalPeerCacheDiscoveryOptions
) {
super();
this.isStarted = false;
this.peers = this.getPeersFromLocalStorage();
}

get [Symbol.toStringTag](): string {
return "@waku/local-discovery";
return "@waku/local-peer-cache-discovery";
}

async start(): Promise<void> {
Expand Down Expand Up @@ -149,12 +149,12 @@ function isValidStoredPeer(peer: any): peer is LocalStoragePeerInfo {
);
}

export function wakuLocalStorageDiscovery(): (
export function wakuLocalPeerCacheDiscovery(): (
components: Libp2pComponents,
options?: LocalStorageDiscoveryOptions
) => LocalStorageDiscovery {
options?: LocalPeerCacheDiscoveryOptions
) => LocalPeerCacheDiscovery {
return (
components: Libp2pComponents,
options?: LocalStorageDiscoveryOptions
) => new LocalStorageDiscovery(components, options);
options?: LocalPeerCacheDiscoveryOptions
) => new LocalPeerCacheDiscovery(components, options);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { MemoryDatastore } from "datastore-core/memory";
import { LocalStorage } from "node-localstorage";
import sinon from "sinon";

import { LocalStorageDiscovery } from "./index.js";
import { LocalPeerCacheDiscovery } from "./index.js";

chai.use(chaiAsPromised);

Expand Down Expand Up @@ -63,17 +63,17 @@ describe("Local Storage Discovery", function () {

tests({
async setup() {
return new LocalStorageDiscovery(components);
return new LocalPeerCacheDiscovery(components);
},
async teardown() {}
});
});

describe("Unit Tests", function () {
let discovery: LocalStorageDiscovery;
let discovery: LocalPeerCacheDiscovery;

beforeEach(async function () {
discovery = new LocalStorageDiscovery(components);
discovery = new LocalPeerCacheDiscovery(components);
await setPeersInLocalStorage(mockPeers);
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@waku/core": "0.0.26",
"@waku/dns-discovery": "0.0.20",
"@waku/interfaces": "0.0.21",
"@waku/local-discovery": "^0.0.1",
"@waku/local-peer-cache-discovery": "^0.0.1",
"@waku/peer-exchange": "^0.0.19",
"@waku/relay": "0.0.9",
"@waku/utils": "0.0.14",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
PubsubTopic,
type ShardInfo
} from "@waku/interfaces";
import { wakuLocalStorageDiscovery } from "@waku/local-discovery";
import { wakuLocalPeerCacheDiscovery } from "@waku/local-peer-cache-discovery";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "@waku/relay";
import { ensureShardingConfigured } from "@waku/utils";
Expand Down Expand Up @@ -194,7 +194,7 @@ export function defaultPeerDiscoveries(
): ((components: Libp2pComponents) => PeerDiscovery)[] {
const discoveries = [
wakuDnsDiscovery([enrTree["PROD"]], DEFAULT_NODE_REQUIREMENTS),
wakuLocalStorageDiscovery(),
wakuLocalPeerCacheDiscovery(),
wakuPeerExchangeDiscovery(pubsubTopics)
];
return discoveries;
Expand Down

0 comments on commit e7993ea

Please sign in to comment.