2022-12-05 17:07:03 +11:00
|
|
|
import type {
|
|
|
|
|
IDecoder,
|
2024-07-26 01:21:52 +03:00
|
|
|
IProtoMessage,
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
IRoutingInfo,
|
2025-07-19 21:25:21 +10:00
|
|
|
ITopicOnlyMessage,
|
|
|
|
|
PubsubTopic
|
2022-12-05 17:07:03 +11:00
|
|
|
} from "@waku/interfaces";
|
2022-12-21 00:48:16 +11:00
|
|
|
import { TopicOnlyMessage as ProtoTopicOnlyMessage } from "@waku/proto";
|
2022-09-19 16:20:33 +10:00
|
|
|
|
2025-06-03 11:08:02 +02:00
|
|
|
export class TopicOnlyMessage implements ITopicOnlyMessage {
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
public get version(): number {
|
|
|
|
|
throw "Only content topic can be accessed on this message";
|
|
|
|
|
}
|
|
|
|
|
public get payload(): Uint8Array {
|
|
|
|
|
throw "Only content topic can be accessed on this message";
|
|
|
|
|
}
|
2022-09-30 12:50:43 +10:00
|
|
|
public rateLimitProof: undefined;
|
|
|
|
|
public timestamp: undefined;
|
2023-03-10 14:41:07 +11:00
|
|
|
public meta: undefined;
|
2022-11-16 11:00:43 +11:00
|
|
|
public ephemeral: undefined;
|
2022-09-30 12:50:43 +10:00
|
|
|
|
2024-07-19 15:58:17 +05:30
|
|
|
public constructor(
|
2023-10-16 12:52:32 +05:30
|
|
|
public pubsubTopic: string,
|
2023-08-16 20:18:13 +05:30
|
|
|
private proto: ProtoTopicOnlyMessage
|
2023-03-10 16:43:21 +11:00
|
|
|
) {}
|
2022-09-19 16:20:33 +10:00
|
|
|
|
2024-07-19 15:58:17 +05:30
|
|
|
public get contentTopic(): string {
|
2023-02-24 23:22:04 +11:00
|
|
|
return this.proto.contentTopic;
|
2022-09-19 16:20:33 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-26 01:21:52 +03:00
|
|
|
// This decoder is used only for reading `contentTopic` from the WakuMessage
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
export class ContentTopicOnlyDecoder implements IDecoder<ITopicOnlyMessage> {
|
|
|
|
|
public constructor() {}
|
|
|
|
|
|
2025-07-19 21:25:21 +10:00
|
|
|
public get pubsubTopic(): PubsubTopic {
|
|
|
|
|
throw "Pubsub Topic is not available on this decoder, it is only meant to decode the content topic for any message";
|
|
|
|
|
}
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
public get contentTopic(): string {
|
|
|
|
|
throw "ContentTopic is not available on this decoder, it is only meant to decode the content topic for any message";
|
|
|
|
|
}
|
2022-09-19 16:20:33 +10:00
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
public get routingInfo(): IRoutingInfo {
|
|
|
|
|
throw "RoutingInfo is not available on this decoder, it is only meant to decode the content topic for any message";
|
|
|
|
|
}
|
2024-07-26 01:21:52 +03:00
|
|
|
|
2024-07-19 15:58:17 +05:30
|
|
|
public fromWireToProtoObj(
|
|
|
|
|
bytes: Uint8Array
|
|
|
|
|
): Promise<IProtoMessage | undefined> {
|
2022-12-21 00:48:16 +11:00
|
|
|
const protoMessage = ProtoTopicOnlyMessage.decode(bytes);
|
2022-09-30 12:50:43 +10:00
|
|
|
return Promise.resolve({
|
|
|
|
|
contentTopic: protoMessage.contentTopic,
|
2023-02-24 23:22:04 +11:00
|
|
|
payload: new Uint8Array(),
|
2022-09-30 12:50:43 +10:00
|
|
|
rateLimitProof: undefined,
|
|
|
|
|
timestamp: undefined,
|
2023-03-10 14:41:07 +11:00
|
|
|
meta: undefined,
|
2022-09-30 12:50:43 +10:00
|
|
|
version: undefined,
|
2023-08-16 20:18:13 +05:30
|
|
|
ephemeral: undefined
|
2022-09-30 12:50:43 +10:00
|
|
|
});
|
2022-09-19 16:20:33 +10:00
|
|
|
}
|
|
|
|
|
|
2024-07-19 15:58:17 +05:30
|
|
|
public async fromProtoObj(
|
2023-10-16 12:52:32 +05:30
|
|
|
pubsubTopic: string,
|
2023-08-16 20:18:13 +05:30
|
|
|
proto: IProtoMessage
|
2025-06-03 11:08:02 +02:00
|
|
|
): Promise<ITopicOnlyMessage | undefined> {
|
2023-10-16 12:52:32 +05:30
|
|
|
return new TopicOnlyMessage(pubsubTopic, proto);
|
2022-09-19 16:20:33 +10:00
|
|
|
}
|
|
|
|
|
}
|