From 833974ad0d1372aeebd79aff377e7ad78542d9e8 Mon Sep 17 00:00:00 2001 From: Billie Hilton <587740+billiegoose@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:45:25 -0400 Subject: [PATCH] oh --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f0f1781..e1d7c5f 100644 --- a/index.js +++ b/index.js @@ -275,10 +275,10 @@ module.exports = class Hyperswarm extends EventEmitter { if (existing) { // If both connections are from the same peer, - // - pick the new one if the existing stream has sent and received bytes, + // - pick the new one if the existing stream is already established (has sent and received bytes), // because the other client must have lost that connection and be reconnecting // - otherwise, pick the one thats expected to initiate in a tie break - const existingIsOutdated = existing.isEstablished() + const existingIsOutdated = existing.rawBytesRead > 0 && existing.rawBytesWritten > 0 const expectedInitiator = b4a.compare(conn.publicKey, conn.remotePublicKey) > 0 const keepNew = existingIsOutdated || (expectedInitiator === conn.isInitiator)