From d7da9b0c72f2a92e5b41993eea9d5cedf2793a57 Mon Sep 17 00:00:00 2001 From: Mohammad Kermani Date: Sat, 5 Oct 2024 11:14:36 +0330 Subject: [PATCH] doc(rosenet-node): add comments describing use case for constants --- .changeset/bright-drinks-help.md | 2 + packages/rosenet-node/lib/constants.ts | 76 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .changeset/bright-drinks-help.md diff --git a/.changeset/bright-drinks-help.md b/.changeset/bright-drinks-help.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/bright-drinks-help.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/rosenet-node/lib/constants.ts b/packages/rosenet-node/lib/constants.ts index b352f8e..a061cd3 100644 --- a/packages/rosenet-node/lib/constants.ts +++ b/packages/rosenet-node/lib/constants.ts @@ -1,21 +1,97 @@ +/** + * How many relays to search for and connect to + */ export const RELAYS_COUNT_TO_CONNECT = 3; +/** + * Minimum relays count below which we try to connect new relays + */ export const MIN_RELAYS = 2; +/** + * Interval for restarting relay discovery to check if MIN_RELAYS threshold is + * reached + */ export const RELAY_DISCOVERY_RESTART_INTERVAL = 10_000; +/** + * RoseNet protocol id + */ export const ROSENET_DIRECT_PROTOCOL_V1 = '/rosenet/direct/1'; +/** + * Default port in which libp2p node will listen to + */ export const DEFAULT_NODE_PORT = 55123; +/** + * A single byte that we wait to receive as an acknowledgement of successful + * message reception + */ export const ACK_BYTE = 1; +/** + * Maximum time that sending a message (writing bytes and receiving ack) can + * take + */ export const MESSAGE_ROUNDTRIP_TIMEOUT = 5000; +/** + * Maximum time that handling an incoming RoseNet Direct can take (calling + * handler and writing ack byte) + */ export const MESSAGE_HANDLING_TIMEOUT = 2000; +/** + * The number of times we attempt to re-send failed messages + */ export const MESSAGE_RETRY_ATTEMPTS = 5; +/** + * Initial delay after which we retry sending a failed message + */ export const MESSAGE_RETRY_INITIAL_DELAY = 2000; +/** + * Maximum number of incoming RoseNet Direct messages that can be handled + * concurrently + */ export const MAX_INBOUND_ROSENET_DIRECT_THROUGHPUT = 100; +/** + * Maximum number of incoming RoseNet Direct messages that can be queued if + * throughput threshold is reached + */ export const MAX_INBOUND_ROSENET_DIRECT_QUEUE_SIZE = 200; +/** + * Maximum number of incoming RoseNet Direct messages from a single peer that + * can be handled concurrently + */ export const MAX_INBOUND_ROSENET_DIRECT_THROUGHPUT_PER_PEER = 10; +/** + * Maximum number of incoming RoseNet Direct messages from a single peer that + * can be queued if throughput threshold is reached + */ export const MAX_INBOUND_ROSENET_DIRECT_QUEUE_SIZE_PER_PEER = 20; +/** + * Maximum number of outgoing RoseNet Direct messages that can be sent + * concurrently + */ export const MAX_OUTBOUND_ROSENET_DIRECT_THROUGHPUT = 200; +/** + * Maximum number of outgoing RoseNet Direct messages that can queued if + * throughput threshold is reached + */ export const MAX_OUTBOUND_ROSENET_DIRECT_QUEUE_SIZE = 400; +/** + * Maximum number of incoming pubsub messages that can be handled concurrently + */ export const MAX_INBOUND_PUBSUB_THROUGHPUT = 100; +/** + * Maximum number of incoming pubsub messages that can be queued if throughput + * threshold is reached + */ export const MAX_INBOUND_PUBSUB_QUEUE_SIZE = 200; +/** + * Maximum number of outgoing pubsub messages that can be sent concurrently + */ export const MAX_OUTBOUND_PUBSUB_THROUGHPUT = 200; +/** + * Maximum number of outgoing pubsub messages that can queued if throughput + * threshold is reached + */ export const MAX_OUTBOUND_PUBSUB_QUEUE_SIZE = 400; +/** + * Maximum time that creation of a stream (including protocol negotiations and + * upgrade) can take + */ export const ROSENET_DIRECT_STREAM_CREATION_TIMEOUT = 2000;