From 6b8981e1db3436246065adff9230bcb67d5f6f5c Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Sat, 12 Aug 2023 00:40:52 -0400 Subject: [PATCH] sync improvements and incompatible upgrade * New Negentropy protocol: Syncs with older versions of strfry will break (sorry!) * Bi-directional frame size limits: fixes a bug when syncing very large DBs where the client side was near empty * sync command now politely tells server it can release Negentropy resources as soon as reconcile complete --- external/negentropy | 2 +- src/apps/mesh/cmd_sync.cpp | 9 +++++++-- src/apps/relay/RelayNegentropy.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/external/negentropy b/external/negentropy index a1b6eed..af0b3d7 160000 --- a/external/negentropy +++ b/external/negentropy @@ -1 +1 @@ -Subproject commit a1b6eed1a4e26f00137a137479712a2531429e9f +Subproject commit af0b3d78748d18759dc2b94d2194e49edc3f7cd2 diff --git a/src/apps/mesh/cmd_sync.cpp b/src/apps/mesh/cmd_sync.cpp index fdc4adc..24ab415 100644 --- a/src/apps/mesh/cmd_sync.cpp +++ b/src/apps/mesh/cmd_sync.cpp @@ -48,7 +48,7 @@ void cmd_sync(const std::vector &subArgs) { tao::json::value filter = tao::json::from_string(filterStr); - Negentropy ne(idSize); + Negentropy ne(idSize, frameSizeLimit); { DBQuery query(filter); @@ -90,7 +90,7 @@ void cmd_sync(const std::vector &subArgs) { ws.reconnect = false; ws.onConnect = [&]{ - auto neMsg = to_hex(ne.initiate(frameSizeLimit)); + auto neMsg = to_hex(ne.initiate()); ws.send(tao::json::to_string(tao::json::value::array({ "NEG-OPEN", "N", @@ -137,6 +137,11 @@ void cmd_sync(const std::vector &subArgs) { if (neMsg.size() == 0) { syncDone = true; LI << "Set reconcile complete. Have " << totalHaves << " need " << totalNeeds; + + ws.send(tao::json::to_string(tao::json::value::array({ + "NEG-CLOSE", + "N", + }))); } else { ws.send(tao::json::to_string(tao::json::value::array({ "NEG-MSG", diff --git a/src/apps/relay/RelayNegentropy.cpp b/src/apps/relay/RelayNegentropy.cpp index 91c24d3..f93e4e9 100644 --- a/src/apps/relay/RelayNegentropy.cpp +++ b/src/apps/relay/RelayNegentropy.cpp @@ -28,7 +28,7 @@ struct NegentropyViews { return false; } - connViews.try_emplace(subId, UserView{ Negentropy(idSize), initialMsg }); + connViews.try_emplace(subId, UserView{ Negentropy(idSize, 500'000), initialMsg }); return true; }