diff --git a/.gitignore b/.gitignore index 1a3c2625c9..08c5d8446c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ test-results playwright-report example allure-results -packages/local-discovery/mock_local_storage \ No newline at end of file +packages/local-peer-cache-discovery/mock_local_storage \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index aa3c64909b..0559c8d980 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "packages/relay", "packages/peer-exchange", "packages/dns-discovery", - "packages/local-discovery", + "packages/local-peer-cache-discovery", "packages/message-encryption", "packages/sdk", "packages/tests", @@ -5479,8 +5479,8 @@ "resolved": "packages/interfaces", "link": true }, - "node_modules/@waku/local-discovery": { - "resolved": "packages/local-discovery", + "node_modules/@waku/local-peer-cache-discovery": { + "resolved": "packages/local-peer-cache-discovery", "link": true }, "node_modules/@waku/message-encryption": { @@ -27920,6 +27920,7 @@ "packages/local-discovery": { "name": "@waku/local-discovery", "version": "0.0.1", + "extraneous": true, "license": "MIT OR Apache-2.0", "dependencies": { "@libp2p/interface": "^1.1.2", @@ -27946,7 +27947,36 @@ "node": ">=18" } }, - "packages/local-discovery/node_modules/@cspell/cspell-bundled-dicts": { + "packages/local-peer-cache-discovery": { + "name": "@waku/local-peer-cache-discovery", + "version": "0.0.1", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@libp2p/interface": "^1.1.2", + "@waku/interfaces": "^0.0.21", + "@waku/utils": "^0.0.14" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.11", + "@types/node-localstorage": "^1.3.3", + "@waku/build-utils": "*", + "chai": "^4.3.10", + "chai-as-promised": "^7.1.1", + "cspell": "^7.3.2", + "mocha": "^10.2.0", + "node-localstorage": "^3.0.5", + "npm-run-all": "^4.1.5", + "rollup": "^4.9.5", + "sinon": "^17.0.1" + }, + "engines": { + "node": ">=18" + } + }, + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-bundled-dicts": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-7.3.9.tgz", "integrity": "sha512-ebfrf5Zaw33bcqT80Qrkv7IGT7GI/CDp15bSk2EUmdORzk1SCKZl6L4vUo3NLMmxVwYioS+OQmsW8E88sJNyGg==", @@ -28005,7 +28035,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/cspell-json-reporter": { + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-json-reporter": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-json-reporter/-/cspell-json-reporter-7.3.9.tgz", "integrity": "sha512-QHsem5OZXshFX+Wdlx3VpdPi9WS7KgoBMGGJ4zQZ3lp81Rb1tRj0Ij/98whq882QOmAVQfr+uOHANHLnyPr0LQ==", @@ -28017,7 +28047,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/cspell-pipe": { + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-pipe": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-7.3.9.tgz", "integrity": "sha512-gKYTHcryKOaTmr6t+M5h1sZnQ42eHeumBJejovphipXfdivedUnuYyQrrQGFAlUKzfEOWcOPME1nm17xsaX5Ww==", @@ -28026,7 +28056,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/cspell-resolver": { + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-resolver": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-7.3.9.tgz", "integrity": "sha512-2slYAGvi7EFLKyJ5hrYBNaFT2iyOEQM1pEIzm+PDuhNJE/9wuBY5pBVqIgFSPz53vsQvW9GJThNY8h1/2EH3ZA==", @@ -28038,7 +28068,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/cspell-service-bus": { + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-service-bus": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-7.3.9.tgz", "integrity": "sha512-VyfK3qWtJZag4Fe/x1Oh/tqCNVGKGlQ2ArX1fVdmTVGQtZcbXuMKdZI80t4b8SGtzGINHufAdakpu3xucX/FrQ==", @@ -28047,7 +28077,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/cspell-types": { + "packages/local-peer-cache-discovery/node_modules/@cspell/cspell-types": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-7.3.9.tgz", "integrity": "sha512-p7s8yEV6ASz0HjiArH11yjNj3vXzK2Ep94GrpdtYJxSxFC2w1mXAVUaJB/5+jC4+1YeYsmcBFTXmZ1rGMyTv3g==", @@ -28056,25 +28086,25 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/dict-cryptocurrencies": { + "packages/local-peer-cache-discovery/node_modules/@cspell/dict-cryptocurrencies": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-4.0.0.tgz", "integrity": "sha512-EiZp91ATyRxTmauIQfOX9adLYCunKjHEh092rrM7o2eMXP9n7zpXAL9BK7LviL+LbB8VDOm21q+s83cKrrRrsg==", "dev": true }, - "packages/local-discovery/node_modules/@cspell/dict-en-common-misspellings": { + "packages/local-peer-cache-discovery/node_modules/@cspell/dict-en-common-misspellings": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@cspell/dict-en-common-misspellings/-/dict-en-common-misspellings-1.0.2.tgz", "integrity": "sha512-jg7ZQZpZH7+aAxNBlcAG4tGhYF6Ksy+QS5Df73Oo+XyckBjC9QS+PrRwLTeYoFIgXy5j3ICParK5r3MSSoL4gw==", "dev": true }, - "packages/local-discovery/node_modules/@cspell/dict-git": { + "packages/local-peer-cache-discovery/node_modules/@cspell/dict-git": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-2.0.0.tgz", "integrity": "sha512-n1AxyX5Kgxij/sZFkxFJlzn3K9y/sCcgVPg/vz4WNJ4K9YeTsUmyGLA2OQI7d10GJeiuAo2AP1iZf2A8j9aj2w==", "dev": true }, - "packages/local-discovery/node_modules/@cspell/dynamic-import": { + "packages/local-peer-cache-discovery/node_modules/@cspell/dynamic-import": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-7.3.9.tgz", "integrity": "sha512-P6tAmDVhrW03hmhetxhBKlNTYwL2lk8ZehYQwSpXaLnaFrS3xrQvfUaJ3Mj9W2CIMzSYXlLmPO2FLRhXK2dnEw==", @@ -28086,7 +28116,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/@cspell/strong-weak-map": { + "packages/local-peer-cache-discovery/node_modules/@cspell/strong-weak-map": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-7.3.9.tgz", "integrity": "sha512-XKpw/p3+EN+PWiFAWc45RJPI9zQRkPSVdUFeZb0YLseWF/CkogScgIe4CLfMLITiVbP0X/FKk90+aTPfAU38kg==", @@ -28095,16 +28125,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/commander": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", - "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", - "dev": true, - "engines": { - "node": ">=16" - } - }, - "packages/local-discovery/node_modules/cspell": { + "packages/local-peer-cache-discovery/node_modules/cspell": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell/-/cspell-7.3.9.tgz", "integrity": "sha512-QzunjO9CmV5+98UfG4ONhvPtrcAC6Y2pEKeOrp5oPeyAI7HwgxmfsR3ybHRlMPAGcwKtDOurBKxM7jqXNwkzmA==", @@ -28140,7 +28161,7 @@ "url": "https://github.com/streetsidesoftware/cspell?sponsor=1" } }, - "packages/local-discovery/node_modules/cspell-dictionary": { + "packages/local-peer-cache-discovery/node_modules/cspell-dictionary": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-7.3.9.tgz", "integrity": "sha512-lkWfX5QNbs4yKqD9wa+G+NHRWmLgFdyposgJOyd/ojDbx99CDPMhMhg9pyMKdYl6Yt8kjMow58/i12EYvD8wnA==", @@ -28156,13 +28177,13 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-dictionary/node_modules/fast-equals": { + "packages/local-peer-cache-discovery/node_modules/cspell-dictionary/node_modules/fast-equals": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-4.0.3.tgz", "integrity": "sha512-G3BSX9cfKttjr+2o1O22tYMLq0DPluZnYtq1rXumE1SpL/F/SLIfHx08WYQoWSIpeMYf8sRbJ8++71+v6Pnxfg==", "dev": true }, - "packages/local-discovery/node_modules/cspell-gitignore": { + "packages/local-peer-cache-discovery/node_modules/cspell-gitignore": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-7.3.9.tgz", "integrity": "sha512-DLuu+K2q4xYNL4DpLyysUeiGU/NYYoObzfOYiISzOKYpi3aFLiUaiyfF6xWGsahmlijif+8bwSsIMmcvGa5dgA==", @@ -28178,7 +28199,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-glob": { + "packages/local-peer-cache-discovery/node_modules/cspell-glob": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-7.3.9.tgz", "integrity": "sha512-7PaTkCzJWjQex3men857v3ExF7Q10jbQkfD+wdln2te9iNFd+HEkstA173vb828D9yeib1q1of8oONr2SeGycg==", @@ -28190,7 +28211,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-grammar": { + "packages/local-peer-cache-discovery/node_modules/cspell-grammar": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-7.3.9.tgz", "integrity": "sha512-s1QOPg4AxWE8XBewDQLe14j0uDyWGjREfm4dZFTrslAZUrQ8/df5s152M5LtgOEza33FrkKKE2axbGvgS9O7sQ==", @@ -28206,7 +28227,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-io": { + "packages/local-peer-cache-discovery/node_modules/cspell-io": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-7.3.9.tgz", "integrity": "sha512-IbXOYaDxLg94uijv13kqb+6PQjEwGboQYtABuZs2+HuUVW89K2tE+fQcEhkAsrZ11sDj5lUqgEQj9omvknZSuA==", @@ -28219,7 +28240,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-lib": { + "packages/local-peer-cache-discovery/node_modules/cspell-lib": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-7.3.9.tgz", "integrity": "sha512-eFYYs8XoYmdu78UxrPisD+hAoXOLaLzcevKf9+oDPDgJmHpkGoFgbIBnHMRIsAM1e+QDS6OlWG/rybhZTqanCQ==", @@ -28252,7 +28273,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/cspell-lib/node_modules/find-up": { + "packages/local-peer-cache-discovery/node_modules/cspell-lib/node_modules/find-up": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz", "integrity": "sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==", @@ -28268,7 +28289,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/local-discovery/node_modules/cspell-trie-lib": { + "packages/local-peer-cache-discovery/node_modules/cspell-trie-lib": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-7.3.9.tgz", "integrity": "sha512-aTWm2KYXjQ+MlM6kB37wmTV9RU8+fgZYkiFfMc48M0MhBc6XkHUibMGrFAS29gp+B70kWPxe+VHLmFIk9pRPyg==", @@ -28282,7 +28303,7 @@ "node": ">=16" } }, - "packages/local-discovery/node_modules/file-entry-cache": { + "packages/local-peer-cache-discovery/node_modules/file-entry-cache": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-7.0.2.tgz", "integrity": "sha512-TfW7/1iI4Cy7Y8L6iqNdZQVvdXn0f8B4QcIXmkIbtTIe/Okm/nSlHb4IwGzRVOd3WfSieCgvf5cMzEfySAIl0g==", @@ -28294,7 +28315,7 @@ "node": ">=12.0.0" } }, - "packages/local-discovery/node_modules/import-meta-resolve": { + "packages/local-peer-cache-discovery/node_modules/import-meta-resolve": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-3.1.1.tgz", "integrity": "sha512-qeywsE/KC3w9Fd2ORrRDUw6nS/nLwZpXgfrOc2IILvZYnCaEMd+D56Vfg9k4G29gIeVi3XKql1RQatME8iYsiw==", @@ -28304,7 +28325,7 @@ "url": "https://github.com/sponsors/wooorm" } }, - "packages/local-discovery/node_modules/locate-path": { + "packages/local-peer-cache-discovery/node_modules/locate-path": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz", "integrity": "sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==", @@ -28319,7 +28340,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/local-discovery/node_modules/p-limit": { + "packages/local-peer-cache-discovery/node_modules/p-limit": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", @@ -28334,7 +28355,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/local-discovery/node_modules/p-locate": { + "packages/local-peer-cache-discovery/node_modules/p-locate": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz", "integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==", @@ -28349,7 +28370,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/local-discovery/node_modules/path-exists": { + "packages/local-peer-cache-discovery/node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", "integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==", @@ -28358,7 +28379,7 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, - "packages/local-discovery/node_modules/yocto-queue": { + "packages/local-peer-cache-discovery/node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", @@ -28552,7 +28573,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", @@ -32582,8 +32603,8 @@ "npm-run-all": "^4.1.5" } }, - "@waku/local-discovery": { - "version": "file:packages/local-discovery", + "@waku/local-peer-cache-discovery": { + "version": "file:packages/local-peer-cache-discovery", "requires": { "@libp2p/interface": "^1.1.2", "@rollup/plugin-commonjs": "^25.0.7", @@ -32729,12 +32750,6 @@ "integrity": "sha512-XKpw/p3+EN+PWiFAWc45RJPI9zQRkPSVdUFeZb0YLseWF/CkogScgIe4CLfMLITiVbP0X/FKk90+aTPfAU38kg==", "dev": true }, - "commander": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", - "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", - "dev": true - }, "cspell": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/cspell/-/cspell-7.3.9.tgz", @@ -33054,7 +33069,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", diff --git a/package.json b/package.json index 7d8eba4b42..970cce7b59 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/interfaces/src/connection_manager.ts b/packages/interfaces/src/connection_manager.ts index 486a48d3d4..339a338684 100644 --- a/packages/interfaces/src/connection_manager.ts +++ b/packages/interfaces/src/connection_manager.ts @@ -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 { diff --git a/packages/local-discovery/.eslintrc.cjs b/packages/local-peer-cache-discovery/.eslintrc.cjs similarity index 100% rename from packages/local-discovery/.eslintrc.cjs rename to packages/local-peer-cache-discovery/.eslintrc.cjs diff --git a/packages/local-discovery/.mocha.reporters.json b/packages/local-peer-cache-discovery/.mocha.reporters.json similarity index 100% rename from packages/local-discovery/.mocha.reporters.json rename to packages/local-peer-cache-discovery/.mocha.reporters.json diff --git a/packages/local-discovery/.mocharc.cjs b/packages/local-peer-cache-discovery/.mocharc.cjs similarity index 100% rename from packages/local-discovery/.mocharc.cjs rename to packages/local-peer-cache-discovery/.mocharc.cjs diff --git a/packages/local-discovery/CHANGELOG.md b/packages/local-peer-cache-discovery/CHANGELOG.md similarity index 100% rename from packages/local-discovery/CHANGELOG.md rename to packages/local-peer-cache-discovery/CHANGELOG.md diff --git a/packages/local-discovery/karma.conf.cjs b/packages/local-peer-cache-discovery/karma.conf.cjs similarity index 100% rename from packages/local-discovery/karma.conf.cjs rename to packages/local-peer-cache-discovery/karma.conf.cjs diff --git a/packages/local-discovery/package.json b/packages/local-peer-cache-discovery/package.json similarity index 90% rename from packages/local-discovery/package.json rename to packages/local-peer-cache-discovery/package.json index 5a45f72e27..445ea9711a 100644 --- a/packages/local-discovery/package.json +++ b/packages/local-peer-cache-discovery/package.json @@ -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": { @@ -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" diff --git a/packages/local-discovery/rollup.config.js b/packages/local-peer-cache-discovery/rollup.config.js similarity index 100% rename from packages/local-discovery/rollup.config.js rename to packages/local-peer-cache-discovery/rollup.config.js diff --git a/packages/local-discovery/src/index.ts b/packages/local-peer-cache-discovery/src/index.ts similarity index 90% rename from packages/local-discovery/src/index.ts rename to packages/local-peer-cache-discovery/src/index.ts index 28549ac756..b6d4efc13c 100644 --- a/packages/local-discovery/src/index.ts +++ b/packages/local-peer-cache-discovery/src/index.ts @@ -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; @@ -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 implements PeerDiscovery, Startable { @@ -37,7 +37,7 @@ export class LocalStorageDiscovery constructor( private readonly components: Libp2pComponents, - private readonly options?: LocalStorageDiscoveryOptions + private readonly options?: LocalPeerCacheDiscoveryOptions ) { super(); this.isStarted = false; @@ -45,7 +45,7 @@ export class LocalStorageDiscovery } get [Symbol.toStringTag](): string { - return "@waku/local-discovery"; + return "@waku/local-peer-cache-discovery"; } async start(): Promise { @@ -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); } diff --git a/packages/local-discovery/src/local_discovery.spec.ts b/packages/local-peer-cache-discovery/src/local_discovery.spec.ts similarity index 95% rename from packages/local-discovery/src/local_discovery.spec.ts rename to packages/local-peer-cache-discovery/src/local_discovery.spec.ts index 23eba055cd..a180fa117f 100644 --- a/packages/local-discovery/src/local_discovery.spec.ts +++ b/packages/local-peer-cache-discovery/src/local_discovery.spec.ts @@ -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); @@ -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); }); diff --git a/packages/local-discovery/tsconfig.dev.json b/packages/local-peer-cache-discovery/tsconfig.dev.json similarity index 100% rename from packages/local-discovery/tsconfig.dev.json rename to packages/local-peer-cache-discovery/tsconfig.dev.json diff --git a/packages/local-discovery/tsconfig.json b/packages/local-peer-cache-discovery/tsconfig.json similarity index 100% rename from packages/local-discovery/tsconfig.json rename to packages/local-peer-cache-discovery/tsconfig.json diff --git a/packages/local-discovery/typedoc.json b/packages/local-peer-cache-discovery/typedoc.json similarity index 100% rename from packages/local-discovery/typedoc.json rename to packages/local-peer-cache-discovery/typedoc.json diff --git a/packages/sdk/package.json b/packages/sdk/package.json index c5fccaaa6e..392608bc5f 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -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", diff --git a/packages/sdk/src/create.ts b/packages/sdk/src/create.ts index c852890caa..22a50b76de 100644 --- a/packages/sdk/src/create.ts +++ b/packages/sdk/src/create.ts @@ -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"; @@ -194,7 +194,7 @@ export function defaultPeerDiscoveries( ): ((components: Libp2pComponents) => PeerDiscovery)[] { const discoveries = [ wakuDnsDiscovery([enrTree["PROD"]], DEFAULT_NODE_REQUIREMENTS), - wakuLocalStorageDiscovery(), + wakuLocalPeerCacheDiscovery(), wakuPeerExchangeDiscovery(pubsubTopics) ]; return discoveries;