mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-24 10:08:15 +00:00
feat!: @waku/relay (#1316)
* move constants & core's func to @waku/utils * setup @waku/relay * use @waku/relay for create * address: principal review * fix: size-limit * move all constants to @waku/core * move TopicOnlyDecoder to relay * merge: master * fix: tests * Move constants out of core (#1340) * update package.lock * change constants folder into a ts file * use dependency version as * instead of version number * add constants import from @waku/core * add empty changelog file for relay --------- Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com>
This commit is contained in:
parent
f4e31019e1
commit
50c2c2540f
@ -30,7 +30,7 @@ module.exports = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Privacy preserving protocols",
|
name: "Privacy preserving protocols",
|
||||||
path: "packages/core/bundle/index.js",
|
path: "packages/relay/bundle/index.js",
|
||||||
import: "{ wakuRelay }",
|
import: "{ wakuRelay }",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
892
package-lock.json
generated
892
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
|||||||
"packages/proto",
|
"packages/proto",
|
||||||
"packages/enr",
|
"packages/enr",
|
||||||
"packages/core",
|
"packages/core",
|
||||||
|
"packages/relay",
|
||||||
"packages/message-hash",
|
"packages/message-hash",
|
||||||
"packages/peer-exchange",
|
"packages/peer-exchange",
|
||||||
"packages/dns-discovery",
|
"packages/dns-discovery",
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
"types": "./dist/lib/message/version_0.d.ts",
|
"types": "./dist/lib/message/version_0.d.ts",
|
||||||
"import": "./dist/lib/message/version_0.js"
|
"import": "./dist/lib/message/version_0.js"
|
||||||
},
|
},
|
||||||
"./lib/message/topic_only_message": {
|
|
||||||
"types": "./dist/lib/message/topic_only_message.d.ts",
|
|
||||||
"import": "./dist/lib/message/topic_only_message.js"
|
|
||||||
},
|
|
||||||
"./lib/base_protocol": {
|
"./lib/base_protocol": {
|
||||||
"types": "./dist/lib/base_protocol.d.ts",
|
"types": "./dist/lib/base_protocol.d.ts",
|
||||||
"import": "./dist/lib/base_protocol.js"
|
"import": "./dist/lib/base_protocol.js"
|
||||||
@ -30,6 +26,9 @@
|
|||||||
"*": {
|
"*": {
|
||||||
"lib/*": [
|
"lib/*": [
|
||||||
"dist/lib/*"
|
"dist/lib/*"
|
||||||
|
],
|
||||||
|
"constants/*": [
|
||||||
|
"dist/constants/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -74,12 +73,10 @@
|
|||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-gossipsub": "^6.1.0",
|
|
||||||
"@libp2p/interface-pubsub": "^3.0.7",
|
|
||||||
"@noble/hashes": "^1.3.0",
|
"@noble/hashes": "^1.3.0",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"@waku/proto": "0.0.4",
|
"@waku/proto": "*",
|
||||||
"@waku/utils": "0.0.5",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"it-all": "^3.0.1",
|
"it-all": "^3.0.1",
|
||||||
"it-length-prefixed": "^9.0.1",
|
"it-length-prefixed": "^9.0.1",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
export { DefaultPubSubTopic } from "./lib/constants.js";
|
|
||||||
export { DefaultUserAgent } from "./lib/waku.js";
|
export { DefaultUserAgent } from "./lib/waku.js";
|
||||||
|
export { DefaultPubSubTopic } from "./lib/constants.js";
|
||||||
export { createEncoder, createDecoder } from "./lib/message/version_0.js";
|
export { createEncoder, createDecoder } from "./lib/message/version_0.js";
|
||||||
export type {
|
export type {
|
||||||
Encoder,
|
Encoder,
|
||||||
@ -18,13 +17,6 @@ export { wakuFilter } from "./lib/filter/index.js";
|
|||||||
export * as waku_light_push from "./lib/light_push/index.js";
|
export * as waku_light_push from "./lib/light_push/index.js";
|
||||||
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
||||||
|
|
||||||
export * as waku_relay from "./lib/relay/index.js";
|
|
||||||
export {
|
|
||||||
wakuRelay,
|
|
||||||
RelayCreateOptions,
|
|
||||||
wakuGossipSub,
|
|
||||||
} from "./lib/relay/index.js";
|
|
||||||
|
|
||||||
export * as waku_store from "./lib/store/index.js";
|
export * as waku_store from "./lib/store/index.js";
|
||||||
export {
|
export {
|
||||||
PageDirection,
|
PageDirection,
|
||||||
|
@ -12,6 +12,7 @@ import type {
|
|||||||
ProtocolOptions,
|
ProtocolOptions,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
import { WakuMessage as WakuMessageProto } from "@waku/proto";
|
import { WakuMessage as WakuMessageProto } from "@waku/proto";
|
||||||
|
import { groupByContentTopic } from "@waku/utils";
|
||||||
import { toAsyncIterator } from "@waku/utils";
|
import { toAsyncIterator } from "@waku/utils";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
import all from "it-all";
|
import all from "it-all";
|
||||||
@ -20,7 +21,6 @@ import { pipe } from "it-pipe";
|
|||||||
|
|
||||||
import { BaseProtocol } from "../base_protocol.js";
|
import { BaseProtocol } from "../base_protocol.js";
|
||||||
import { DefaultPubSubTopic } from "../constants.js";
|
import { DefaultPubSubTopic } from "../constants.js";
|
||||||
import { groupByContentTopic } from "../group_by.js";
|
|
||||||
import { toProtoMessage } from "../to_proto_message.js";
|
import { toProtoMessage } from "../to_proto_message.js";
|
||||||
|
|
||||||
import { ContentFilter, FilterRpc } from "./filter_rpc.js";
|
import { ContentFilter, FilterRpc } from "./filter_rpc.js";
|
||||||
|
@ -5,8 +5,7 @@ import type { Libp2p } from "libp2p";
|
|||||||
|
|
||||||
import { createEncoder } from "../index.js";
|
import { createEncoder } from "../index.js";
|
||||||
|
|
||||||
import { RelayPingContentTopic } from "./relay/constants.js";
|
export const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
||||||
|
|
||||||
const log = debug("waku:keep-alive");
|
const log = debug("waku:keep-alive");
|
||||||
|
|
||||||
export interface KeepAliveOptions {
|
export interface KeepAliveOptions {
|
||||||
|
@ -1,2 +1 @@
|
|||||||
export * as version_0 from "./version_0.js";
|
export * as version_0 from "./version_0.js";
|
||||||
export * as topic_only_message from "./topic_only_message.js";
|
|
||||||
|
@ -51,8 +51,9 @@
|
|||||||
"@chainsafe/libp2p-noise": "^11.0.0",
|
"@chainsafe/libp2p-noise": "^11.0.0",
|
||||||
"@libp2p/mplex": "^7.1.1",
|
"@libp2p/mplex": "^7.1.1",
|
||||||
"@libp2p/websockets": "^5.0.3",
|
"@libp2p/websockets": "^5.0.3",
|
||||||
"@waku/core": "0.0.17",
|
"@waku/relay": "*",
|
||||||
"@waku/dns-discovery": "0.0.11",
|
"@waku/core": "*",
|
||||||
|
"@waku/dns-discovery": "*",
|
||||||
"libp2p": "^0.42.2"
|
"libp2p": "^0.42.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -76,7 +77,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||||
"@typescript-eslint/parser": "^5.51.0",
|
"@typescript-eslint/parser": "^5.51.0",
|
||||||
"@waku/build-utils": "*",
|
"@waku/build-utils": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"cspell": "^6.31.1",
|
"cspell": "^6.31.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
|
@ -7,13 +7,10 @@ import { webSockets } from "@libp2p/websockets";
|
|||||||
import { all as filterAll } from "@libp2p/websockets/filters";
|
import { all as filterAll } from "@libp2p/websockets/filters";
|
||||||
import {
|
import {
|
||||||
DefaultUserAgent,
|
DefaultUserAgent,
|
||||||
RelayCreateOptions,
|
|
||||||
wakuFilter,
|
wakuFilter,
|
||||||
wakuGossipSub,
|
|
||||||
wakuLightPush,
|
wakuLightPush,
|
||||||
WakuNode,
|
WakuNode,
|
||||||
WakuOptions,
|
WakuOptions,
|
||||||
wakuRelay,
|
|
||||||
wakuStore,
|
wakuStore,
|
||||||
} from "@waku/core";
|
} from "@waku/core";
|
||||||
import { enrTree, wakuDnsDiscovery } from "@waku/dns-discovery";
|
import { enrTree, wakuDnsDiscovery } from "@waku/dns-discovery";
|
||||||
@ -23,6 +20,7 @@ import type {
|
|||||||
ProtocolCreateOptions,
|
ProtocolCreateOptions,
|
||||||
RelayNode,
|
RelayNode,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
|
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "@waku/relay";
|
||||||
import { createLibp2p, Libp2pOptions } from "libp2p";
|
import { createLibp2p, Libp2pOptions } from "libp2p";
|
||||||
|
|
||||||
import type { Libp2pComponents } from "./libp2p_components.js";
|
import type { Libp2pComponents } from "./libp2p_components.js";
|
||||||
|
@ -60,8 +60,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.5",
|
"@libp2p/interface-peer-discovery": "^1.0.5",
|
||||||
"@libp2p/interfaces": "^3.3.1",
|
"@libp2p/interfaces": "^3.3.1",
|
||||||
"@waku/enr": "0.0.11",
|
"@waku/enr": "*",
|
||||||
"@waku/utils": "0.0.5",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"dns-query": "^0.11.2",
|
"dns-query": "^0.11.2",
|
||||||
"hi-base32": "^0.5.1",
|
"hi-base32": "^0.5.1",
|
||||||
@ -80,7 +80,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||||
"@typescript-eslint/parser": "^5.51.0",
|
"@typescript-eslint/parser": "^5.51.0",
|
||||||
"@waku/build-utils": "*",
|
"@waku/build-utils": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.7",
|
"chai": "^4.3.7",
|
||||||
"cspell": "^6.31.1",
|
"cspell": "^6.31.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
"@libp2p/peer-id": "^2.0.3",
|
"@libp2p/peer-id": "^2.0.3",
|
||||||
"@multiformats/multiaddr": "^12.0.0",
|
"@multiformats/multiaddr": "^12.0.0",
|
||||||
"@noble/secp256k1": "^1.7.1",
|
"@noble/secp256k1": "^1.7.1",
|
||||||
"@waku/utils": "0.0.5",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"js-sha3": "^0.8.0"
|
"js-sha3": "^0.8.0"
|
||||||
},
|
},
|
||||||
|
@ -72,10 +72,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/secp256k1": "^1.7.1",
|
"@noble/secp256k1": "^1.7.1",
|
||||||
"@waku/core": "0.0.17",
|
"@waku/core": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"@waku/proto": "0.0.4",
|
"@waku/proto": "*",
|
||||||
"@waku/utils": "0.0.5",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"js-sha3": "^0.8.0"
|
"js-sha3": "^0.8.0"
|
||||||
},
|
},
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/hashes": "^1.2.0",
|
"@noble/hashes": "^1.2.0",
|
||||||
"@waku/utils": "0.0.5"
|
"@waku/utils": "*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^24.0.1",
|
"@rollup/plugin-commonjs": "^24.0.1",
|
||||||
@ -65,7 +65,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
||||||
"@typescript-eslint/parser": "^5.51.0",
|
"@typescript-eslint/parser": "^5.51.0",
|
||||||
"@waku/build-utils": "*",
|
"@waku/build-utils": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.7",
|
"chai": "^4.3.7",
|
||||||
"cspell": "^6.28.0",
|
"cspell": "^6.28.0",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
|
@ -50,10 +50,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.5",
|
"@libp2p/interface-peer-discovery": "^1.0.5",
|
||||||
"@libp2p/interfaces": "^3.3.1",
|
"@libp2p/interfaces": "^3.3.1",
|
||||||
"@waku/core": "0.0.17",
|
"@waku/core": "*",
|
||||||
"@waku/enr": "0.0.11",
|
"@waku/enr": "*",
|
||||||
"@waku/proto": "0.0.4",
|
"@waku/proto": "*",
|
||||||
"@waku/utils": "0.0.5",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"it-all": "^3.0.1",
|
"it-all": "^3.0.1",
|
||||||
"it-length-prefixed": "^9.0.1",
|
"it-length-prefixed": "^9.0.1",
|
||||||
@ -71,7 +71,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||||
"@typescript-eslint/parser": "^5.51.0",
|
"@typescript-eslint/parser": "^5.51.0",
|
||||||
"@waku/build-utils": "*",
|
"@waku/build-utils": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.7",
|
"chai": "^4.3.7",
|
||||||
"cspell": "^6.31.1",
|
"cspell": "^6.31.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
|
6
packages/relay/.eslintrc.cjs
Normal file
6
packages/relay/.eslintrc.cjs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
project: "./tsconfig.dev.json",
|
||||||
|
},
|
||||||
|
};
|
11
packages/relay/.mocharc.json
Normal file
11
packages/relay/.mocharc.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"extension": ["ts"],
|
||||||
|
"spec": "src/**/*.spec.ts",
|
||||||
|
"require": ["ts-node/register", "isomorphic-fetch"],
|
||||||
|
"loader": "ts-node/esm",
|
||||||
|
"node-option": [
|
||||||
|
"experimental-specifier-resolution=node",
|
||||||
|
"loader=ts-node/esm"
|
||||||
|
],
|
||||||
|
"exit": true
|
||||||
|
}
|
0
packages/relay/CHANGELOG.md
Normal file
0
packages/relay/CHANGELOG.md
Normal file
6773
packages/relay/package-lock.json
generated
Normal file
6773
packages/relay/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
93
packages/relay/package.json
Normal file
93
packages/relay/package.json
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
{
|
||||||
|
"name": "@waku/relay",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "Relay Protocol for Waku",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"module": "./dist/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"import": "./dist/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"typesVersions": {
|
||||||
|
"*": {
|
||||||
|
"lib/*": [
|
||||||
|
"dist/lib/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/relay#readme",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/waku-org/js-waku.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/waku-org/js-waku/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT OR Apache-2.0",
|
||||||
|
"keywords": [
|
||||||
|
"waku",
|
||||||
|
"decentralised",
|
||||||
|
"communication",
|
||||||
|
"web3",
|
||||||
|
"ethereum",
|
||||||
|
"dapps"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "run-s build:**",
|
||||||
|
"build:esm": "tsc",
|
||||||
|
"build:bundle": "rollup --config rollup.config.js",
|
||||||
|
"fix": "run-s fix:*",
|
||||||
|
"fix:lint": "eslint src *.js --fix",
|
||||||
|
"pretest": "run-s pretest:*",
|
||||||
|
"check": "run-s check:*",
|
||||||
|
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||||
|
"check:lint": "eslint src *.js",
|
||||||
|
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||||
|
"test": "run-s test:*",
|
||||||
|
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
|
||||||
|
"watch:build": "tsc -p tsconfig.json -w",
|
||||||
|
"watch:test": "mocha --watch",
|
||||||
|
"prepublish": "npm run build",
|
||||||
|
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@chainsafe/libp2p-gossipsub": "^6.1.0",
|
||||||
|
"@noble/hashes": "^1.3.0",
|
||||||
|
"@waku/build-utils": "*",
|
||||||
|
"@waku/core": "*",
|
||||||
|
"@waku/interfaces": "*",
|
||||||
|
"@waku/proto": "*",
|
||||||
|
"@waku/utils": "*",
|
||||||
|
"chai": "^4.3.7",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"fast-check": "^3.8.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^24.1.0",
|
||||||
|
"@rollup/plugin-json": "^6.0.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
||||||
|
"rollup": "^3.15.0",
|
||||||
|
"ts-loader": "^9.4.2",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
|
"typescript": "^4.9.5"
|
||||||
|
},
|
||||||
|
"typedoc": {
|
||||||
|
"entryPoint": "./src/index.ts"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"bundle",
|
||||||
|
"src/**/*.ts",
|
||||||
|
"!**/*.spec.*",
|
||||||
|
"!**/*.json",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
]
|
||||||
|
}
|
24
packages/relay/rollup.config.js
Normal file
24
packages/relay/rollup.config.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
|
import json from "@rollup/plugin-json";
|
||||||
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||||
|
import { extractExports } from "@waku/build-utils";
|
||||||
|
|
||||||
|
import * as packageJson from "./package.json" assert { type: "json" };
|
||||||
|
|
||||||
|
const input = extractExports(packageJson);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input,
|
||||||
|
output: {
|
||||||
|
dir: "bundle",
|
||||||
|
format: "esm",
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
commonjs(),
|
||||||
|
json(),
|
||||||
|
nodeResolve({
|
||||||
|
browser: true,
|
||||||
|
preferBuiltins: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
@ -6,8 +6,6 @@ export const minute = 60 * second;
|
|||||||
*/
|
*/
|
||||||
export const RelayCodecs = ["/vac/waku/relay/2.0.0"];
|
export const RelayCodecs = ["/vac/waku/relay/2.0.0"];
|
||||||
|
|
||||||
export const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.
|
* RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.
|
||||||
* We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or
|
* We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or
|
@ -9,6 +9,7 @@ import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
|
|||||||
import type { Libp2p } from "@libp2p/interface-libp2p";
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PubSub } from "@libp2p/interface-pubsub";
|
import type { PubSub } from "@libp2p/interface-pubsub";
|
||||||
import { sha256 } from "@noble/hashes/sha256";
|
import { sha256 } from "@noble/hashes/sha256";
|
||||||
|
import { DefaultPubSubTopic } from "@waku/core";
|
||||||
import type {
|
import type {
|
||||||
ActiveSubscriptions,
|
ActiveSubscriptions,
|
||||||
Callback,
|
Callback,
|
||||||
@ -22,15 +23,12 @@ import type {
|
|||||||
ProtocolOptions,
|
ProtocolOptions,
|
||||||
SendResult,
|
SendResult,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
import { toAsyncIterator } from "@waku/utils";
|
import { groupByContentTopic, toAsyncIterator } from "@waku/utils";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
import { DefaultPubSubTopic } from "../constants.js";
|
import { RelayCodecs } from "./constants.js";
|
||||||
import { groupByContentTopic } from "../group_by.js";
|
|
||||||
import { TopicOnlyDecoder } from "../message/topic_only_message.js";
|
|
||||||
|
|
||||||
import * as constants from "./constants.js";
|
|
||||||
import { messageValidator } from "./message_validator.js";
|
import { messageValidator } from "./message_validator.js";
|
||||||
|
import { TopicOnlyDecoder } from "./topic_only_message.js";
|
||||||
|
|
||||||
const log = debug("waku:relay");
|
const log = debug("waku:relay");
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ class Relay implements IRelay {
|
|||||||
private readonly pubSubTopic: string;
|
private readonly pubSubTopic: string;
|
||||||
private defaultDecoder: IDecoder<IDecodedMessage>;
|
private defaultDecoder: IDecoder<IDecodedMessage>;
|
||||||
|
|
||||||
public static multicodec: string = constants.RelayCodecs[0];
|
public static multicodec: string = RelayCodecs[0];
|
||||||
public readonly gossipSub: GossipSub;
|
public readonly gossipSub: GossipSub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,7 +243,7 @@ export function wakuGossipSub(
|
|||||||
fallbackToFloodsub: false,
|
fallbackToFloodsub: false,
|
||||||
};
|
};
|
||||||
const pubsub = new GossipSub(components, init);
|
const pubsub = new GossipSub(components, init);
|
||||||
pubsub.multicodecs = constants.RelayCodecs;
|
pubsub.multicodecs = RelayCodecs;
|
||||||
return pubsub;
|
return pubsub;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,11 +1,10 @@
|
|||||||
import { TopicValidatorResult } from "@libp2p/interface-pubsub";
|
import { TopicValidatorResult } from "@libp2p/interface-pubsub";
|
||||||
import type { UnsignedMessage } from "@libp2p/interface-pubsub";
|
import type { UnsignedMessage } from "@libp2p/interface-pubsub";
|
||||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||||
|
import { createEncoder } from "@waku/core";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import fc from "fast-check";
|
import fc from "fast-check";
|
||||||
|
|
||||||
import { createEncoder } from "../message/version_0.js";
|
|
||||||
|
|
||||||
import { messageValidator } from "./message_validator.js";
|
import { messageValidator } from "./message_validator.js";
|
||||||
|
|
||||||
describe("Message Validator", () => {
|
describe("Message Validator", () => {
|
3
packages/relay/tsconfig.dev.json
Normal file
3
packages/relay/tsconfig.dev.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.dev"
|
||||||
|
}
|
10
packages/relay/tsconfig.json
Normal file
10
packages/relay/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist/",
|
||||||
|
"rootDir": "src",
|
||||||
|
"tsBuildInfoFile": "dist/.tsbuildinfo"
|
||||||
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
|
||||||
|
}
|
@ -78,7 +78,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||||
"@typescript-eslint/parser": "^5.51.0",
|
"@typescript-eslint/parser": "^5.51.0",
|
||||||
"@waku/build-utils": "*",
|
"@waku/build-utils": "*",
|
||||||
"@waku/interfaces": "0.0.12",
|
"@waku/interfaces": "*",
|
||||||
"cspell": "^6.31.1",
|
"cspell": "^6.31.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export * from "./is_defined.js";
|
export * from "./is_defined.js";
|
||||||
export * from "./random_subset.js";
|
export * from "./random_subset.js";
|
||||||
|
export * from "./group_by.js";
|
||||||
export * from "./to_async_iterator.js";
|
export * from "./to_async_iterator.js";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user