mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-18 17:27:11 +00:00
frame size limit for negentropy syncs
This commit is contained in:
@ -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