Skip to content

Commit

Permalink
oh
Browse files Browse the repository at this point in the history
  • Loading branch information
billiegoose committed Jun 26, 2024
1 parent 19bc839 commit 833974a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 833974a

Please sign in to comment.