mirror of
https://github.com/Yonle/bostr.git
synced 2025-10-01 18:06:37 +02:00
bouncer: fix duplicates being forwarded to client.
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
@@ -60,8 +60,9 @@ module.exports = {
|
||||
// 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,
|
||||
// Setting as 0 will store known events to memory without limit until the subscription is closed.
|
||||
// Reduce this value if memory usage is high. But don't go too low as duplicates will be forwarded to client.
|
||||
max_known_events: 0,
|
||||
|
||||
// Wait for every connected relays send EOSE.
|
||||
// Could improve accuracy on received events.
|
||||
|
@@ -318,7 +318,7 @@ function newConn(addr, id, reconn_t = 0) {
|
||||
if (!client.subalias.hasOwnProperty(data[1])) return;
|
||||
data[1] = client.subalias[data[1]];
|
||||
|
||||
if (client.events[data[1]].hasOwnProperty(data[2]?.id)) return; // No need to transmit once it has been transmitted before.
|
||||
if (client.events[data[1]].has(data[2]?.id)) return; // No need to transmit once it has been transmitted before.
|
||||
if (!relay.isCache) bc(["EVENT", data[2]], id, true); // store to cache relay
|
||||
const filter = client.mergedFilters[data[1]];
|
||||
if (client.pause_subs.has(data[1]) && (filter.since > data[2].created_at) && !relay.isCache) return;
|
||||
@@ -334,7 +334,7 @@ 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)
|
||||
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++;
|
||||
|
Reference in New Issue
Block a user