mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-16 16:28:50 +00:00
frame size limit for negentropy syncs
This commit is contained in:
2
external/negentropy
vendored
2
external/negentropy
vendored
Submodule external/negentropy updated: 4a9bd3b9be...a1b6eed1a4
2
golpe
2
golpe
Submodule golpe updated: 79ae8de092...3b61bd2d17
@ -79,7 +79,7 @@ class WSConnection {
|
||||
});
|
||||
|
||||
hubGroup->onDisconnection([&](uWS::WebSocket<uWS::CLIENT> *ws, int code, char *message, size_t length) {
|
||||
LI << "Disconnected";
|
||||
LI << "Disconnected: " << code << "/" << (message ? std::string_view(message, length) : "-");
|
||||
|
||||
if (ws == currWs) {
|
||||
currWs = nullptr;
|
||||
|
@ -16,11 +16,12 @@
|
||||
static const char USAGE[] =
|
||||
R"(
|
||||
Usage:
|
||||
sync <url> [--filter=<filter>] [--dir=<dir>]
|
||||
sync <url> [--filter=<filter>] [--dir=<dir>] [--frame-size-limit=<frame-size-limit>]
|
||||
|
||||
Options:
|
||||
--filter=<filter> Nostr filter (either single filter object or array of filters)
|
||||
--dir=<dir> Direction: both, down, up, none [default: both]
|
||||
--frame-size-limit=<frame-size-limit> Limit outgoing negentropy message size (default 60k, 0 for no limit)
|
||||
)";
|
||||
|
||||
|
||||
@ -36,6 +37,9 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
|
||||
std::string dir = args["--dir"] ? args["--dir"].asString() : "both";
|
||||
if (dir != "both" && dir != "up" && dir != "down" && dir != "none") throw herr("invalid direction: ", dir, ". Should be one of both/up/down/none");
|
||||
|
||||
uint64_t frameSizeLimit = 0;
|
||||
if (args["--frame-size-limit"]) frameSizeLimit = args["--frame-size-limit"].asLong();
|
||||
|
||||
const uint64_t idSize = 16;
|
||||
const bool doUp = dir == "both" || dir == "up";
|
||||
const bool doDown = dir == "both" || dir == "down";
|
||||
@ -80,7 +84,7 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
|
||||
ws.reconnect = false;
|
||||
|
||||
ws.onConnect = [&]{
|
||||
auto neMsg = to_hex(ne.initiate());
|
||||
auto neMsg = to_hex(ne.initiate(frameSizeLimit));
|
||||
ws.send(tao::json::to_string(tao::json::value::array({
|
||||
"NEG-OPEN",
|
||||
"N",
|
||||
|
Reference in New Issue
Block a user