mirror of
https://github.com/Yonle/bostr.git
synced 2025-03-19 14:21:54 +01:00
conf & bouncer: introducing max_known_events configuration
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
parent
c8dfe77fc8
commit
63a653ae51
@ -57,6 +57,12 @@ module.exports = {
|
||||
// Setting as -1 will disable max subscription limit.
|
||||
max_client_subs: -1,
|
||||
|
||||
// Maximum Known Events
|
||||
// Used for knowing what events has been forwarded to client in order to prevent duplicates to be forwarded.
|
||||
//
|
||||
// Setting as 0 will store known events to memory without limits.
|
||||
max_known_events: 1000,
|
||||
|
||||
// Wait for every connected relays send EOSE.
|
||||
// Could improve accuracy on received events.
|
||||
//
|
||||
|
@ -7,7 +7,7 @@ const WebSocket = require("ws");
|
||||
const { validateEvent, nip19, matchFilters, mergeFilters, getFilterLimit } = require("nostr-tools");
|
||||
const nip42 = require("./nip42.js");
|
||||
|
||||
let { relays, log_about_relays, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, loadbalancer } = require(process.env.BOSTR_CONFIG_PATH || "./config");
|
||||
let { relays, log_about_relays, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, loadbalancer, max_known_events } = require(process.env.BOSTR_CONFIG_PATH || "./config");
|
||||
|
||||
log_about_relays = process.env.LOG_ABOUT_RELAYS || log_about_relays;
|
||||
|
||||
@ -331,6 +331,9 @@ function newConn(addr, id, reconn_t = 0) {
|
||||
if (!relay.isLoadBalancer) client.events[data[1]].add(data[2]?.id);
|
||||
parentPort.postMessage({ type: "upstream_msg", id, data: JSON.stringify(data) });
|
||||
|
||||
if (max_known_events && client.events[data[1]].size > max_known_events)
|
||||
client.events[data[1]].delete(client.events[data[1]].values().next().value);
|
||||
|
||||
stats._global.rx++;
|
||||
stats[addr].rx++;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user