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
This commit is contained in:
Doug Hoyte
2023-08-12 00:40:52 -04:00
parent d189cdb349
commit 6b8981e1db
3 changed files with 9 additions and 4 deletions

View File

@ -48,7 +48,7 @@ void cmd_sync(const std::vector<std::string> &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<std::string> &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<std::string> &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",

View File

@ -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;
}