From a3b4e7baf51e50e6e55707ed1b61d7359a18fe24 Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Sun, 11 Jun 2023 23:44:33 -0400 Subject: [PATCH] frame size limit for negentropy syncs --- external/negentropy | 2 +- golpe | 2 +- src/WSConnection.h | 2 +- src/apps/mesh/cmd_sync.cpp | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/external/negentropy b/external/negentropy index 4a9bd3b..a1b6eed 160000 --- a/external/negentropy +++ b/external/negentropy @@ -1 +1 @@ -Subproject commit 4a9bd3b9be6616b51fc6b80e34bed10ac129e1a7 +Subproject commit a1b6eed1a4e26f00137a137479712a2531429e9f diff --git a/golpe b/golpe index 79ae8de..3b61bd2 160000 --- a/golpe +++ b/golpe @@ -1 +1 @@ -Subproject commit 79ae8de0923ad3112fbde4fc8e224501c5e49a79 +Subproject commit 3b61bd2d173759dc8c2effa636089e5b8c81efb8 diff --git a/src/WSConnection.h b/src/WSConnection.h index 9ecfdfb..b84150f 100644 --- a/src/WSConnection.h +++ b/src/WSConnection.h @@ -79,7 +79,7 @@ class WSConnection { }); hubGroup->onDisconnection([&](uWS::WebSocket *ws, int code, char *message, size_t length) { - LI << "Disconnected"; + LI << "Disconnected: " << code << "/" << (message ? std::string_view(message, length) : "-"); if (ws == currWs) { currWs = nullptr; diff --git a/src/apps/mesh/cmd_sync.cpp b/src/apps/mesh/cmd_sync.cpp index 4061ac5..3a7255e 100644 --- a/src/apps/mesh/cmd_sync.cpp +++ b/src/apps/mesh/cmd_sync.cpp @@ -16,11 +16,12 @@ static const char USAGE[] = R"( Usage: - sync [--filter=] [--dir=] + sync [--filter=] [--dir=] [--frame-size-limit=] Options: --filter= Nostr filter (either single filter object or array of filters) --dir= Direction: both, down, up, none [default: both] + --frame-size-limit= Limit outgoing negentropy message size (default 60k, 0 for no limit) )"; @@ -36,6 +37,9 @@ void cmd_sync(const std::vector &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 &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",