mirror of
https://github.com/Yonle/bostr.git
synced 2025-03-17 21:32:43 +01:00
introduce max EOSE score in config
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
parent
e9fa7e19ee
commit
ac14c698dc
@ -3,13 +3,16 @@ const { validateEvent, nip19 } = require("nostr-tools");
|
||||
const auth = require("./auth.js");
|
||||
const nip42 = require("./nip42.js");
|
||||
|
||||
let { relays, tmp_store, log_about_relays, authorized_keys, private_keys, reconnect_time, wait_eose, pause_on_limit, eose_timeout } = require("./config");
|
||||
let { relays, tmp_store, log_about_relays, authorized_keys, private_keys, reconnect_time, wait_eose, pause_on_limit, eose_timeout, max_eose_score } = require("./config");
|
||||
|
||||
const socks = new Set();
|
||||
const csess = new Map();
|
||||
|
||||
authorized_keys = authorized_keys?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
||||
|
||||
// CL MaxEoseScore: Set <max_eose_score> as 0 if configured relays is under of the expected number from <max_eose_score>
|
||||
if (relays.length < max_eose_score) max_eose_score = 0;
|
||||
|
||||
// CL - User socket
|
||||
module.exports = (ws, req) => {
|
||||
let authKey = null;
|
||||
@ -226,7 +229,8 @@ function newConn(addr, id) {
|
||||
case "EOSE":
|
||||
if (!client.pendingEOSE.has(data[1])) return;
|
||||
client.pendingEOSE.set(data[1], client.pendingEOSE.get(data[1]) + 1);
|
||||
if (wait_eose && (client.pendingEOSE.get(data[1]) < Array.from(socks).filter(sock => sock.id === id).length)) return;
|
||||
if (process.env.LOG_ABOUT_RELAYS || log_about_relays) console.log(process.pid, "---", `[${id}]`, `got EOSE from ${ws.url} for ${data[1]}. There are ${client.pendingEOSE.get(data[1])} EOSE received out of ${Array.from(socks).filter(sock => sock.id === id).length} connected relays.`);
|
||||
if (wait_eose && (client.pendingEOSE.get(data[1]) < (max_eose_score || Array.from(socks).filter(sock => sock.id === id).length))) return;
|
||||
client.pendingEOSE.delete(data[1]);
|
||||
cancel_EOSETimeout(data[1]);
|
||||
if (client.pause_subs.has(data[1])) return client.pause_subs.delete(data[1]);
|
||||
|
@ -21,8 +21,8 @@ module.exports = {
|
||||
//
|
||||
// Depending on your configured relays,
|
||||
// It may could cause loading problems in client due to slow EOSE from bouncer.
|
||||
// You could try fix this by changing <eose_timeout> value.
|
||||
wait_eose: false,
|
||||
// You could try fix this by changing <eose_timeout> or <max_eose_score> value.
|
||||
wait_eose: true,
|
||||
|
||||
// Pause an subscription from receiving further events after reached to <filter.limit>
|
||||
// Could save client's bandwdith.
|
||||
@ -33,6 +33,12 @@ module.exports = {
|
||||
// EOSE timeout in miliseconds
|
||||
eose_timeout: 2300,
|
||||
|
||||
// Maximum of received EOSE from relays to send EOSE to client.
|
||||
// Normally, waiting EOSE from 3 relays should be enough. Leaving it with 0 equals wait for every established relays.
|
||||
// NOTE: Please adjust this max score correctly with your configured relays.
|
||||
// If you only setted up 3 relays, Set the <max_eose_score> as 0.
|
||||
max_eose_score: 3,
|
||||
|
||||
// A whitelist of users public keys who could use this bouncer.
|
||||
// Leaving this empty will allows everyone to use this bouncer.
|
||||
// NOTE: - Require NIP-42 compatible nostr client
|
||||
|
Loading…
x
Reference in New Issue
Block a user