Fully rewrite relay

This commit is contained in:
Danny Morabito 2025-06-04 12:43:23 +02:00
parent 190e38dfc1
commit 20ffbd4c6d
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 7CC8056A5A04557E
47 changed files with 3489 additions and 128 deletions

59
src/consts.ts Normal file
View file

@ -0,0 +1,59 @@
/**
* Minimum required Proof of Work (PoW) difficulty for note acceptance.
*
* Notes with PoW below this threshold will be rejected without decryption attempts.
* This threshold serves as a DoS protection mechanism for the CCN in case of
* public key compromise.
*/
export const MIN_POW = 8;
/**
* Target Proof of Work (PoW) difficulty for relay-generated notes.
*
* Defines the PoW difficulty level that the relay will compute when generating
* and encrypting its own notes before broadcasting them to the network.
*
* Expected Performance on modern hardware (2025):
* - Difficulty 8: ~1ms
* - Difficulty 21: ~5-6 seconds
*/
export const POW_TO_MINE = 10;
/**
* Maximum size of a note chunk in bytes.
*
* This value determines the maximum size of a note that can be encrypted and
* sent in a single chunk.
*/
export const MAX_CHUNK_SIZE = 32768;
/**
* Interval for cleaning up expired note chunks in milliseconds.
*
* This value determines how often the relay will check for and remove expired
* note chunks from the database.
*/
export const CHUNK_CLEANUP_INTERVAL = 1000 * 60 * 60;
/**
* Maximum age of a note chunk in milliseconds.
*
* This value determines the maximum duration a note chunk can remain in the
* database before it is considered expired and eligible for cleanup.
*/
export const CHUNK_MAX_AGE = 1000 * 60 * 60 * 24;
/**
* Interval for processing the outbound event queue in milliseconds.
*
* This determines how often the relay will attempt to send pending events
* to external relays.
*/
export const QUEUE_PROCESS_INTERVAL = 10000;
/**
* Maximum number of transmission attempts for outbound events.
*
* Events that fail to transmit this many times will be marked as permanently failed.
*/
export const MAX_TRANSMISSION_ATTEMPTS = 5;