Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

fix(sessions): explicitly connect found peers #56

Merged
merged 3 commits into from
Jan 11, 2019

Conversation

hannahhoward
Copy link
Contributor

Goal

When providers are found in a session, explicitly connect them so they get added to the peer manager
fix #53

Implementation

  • For now, copy the code that is used by the providerQueryWorker to connect newly found providers (this will be removed when we address Deduplicate provider logic #52)
  • Add a test which demonstrates the failing case for this behavior (fetching blocks from a peer that is not already connected), and verify changes resolve it

For Discussion

n/a

when providers are found in a session, explicitly connect them so they get added to the peer manager

fix #53
@ghost ghost assigned hannahhoward Jan 10, 2019
@ghost ghost added the status/in-progress In progress label Jan 10, 2019
@@ -222,7 +222,7 @@ func (s *Session) SetBaseTickDelay(baseTickDelay time.Duration) {
}
}

const provSearchDelay = time.Second * 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty low. What was the reasoning behind this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match time time for regular GetBlocks in Bitswap w/o sessions... especially if we're going to merge these two.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But transparently in this case, for testing. And it should be configurable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match time time for regular GetBlocks in Bitswap w/o sessions... especially if we're going to merge these two.

The timer for GetBlocks is a bit different. That's an initial delay before finding a provider for a single block. In the past, we didn't even delay this. Subsequent FindProviders calls are controlled by the rebroadcastWorker and sent out every 10 seconds (for random blocks).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea in this case, after a block is received, it switches over to using the tick delay, which is 500ms + 3 * average latency per block. So, somewhat similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provSearchDelay is only used at the beginning of a session for the first call to FindProvidersAsync, if no blocks come back from any peers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Yeah, that makes total sense.

(thanks for digging into this)

}
wg.Wait()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We don't really need to wait here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true I think... though we may need to once we dedup with providers worker. But agreed, maybe I'll remove wait group knowledge for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really matter.

@hannahhoward
Copy link
Contributor Author

@Stebalien I went ahead and removed the waitgroup code just for now and made the provSearchDelay configurable (without changing the default value).

I'd like to revisit the default value issue when I work on making regular GetBlocks just use sessions (see comments above), but for now, this should work.

Lemme know if this is LGTM

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You can also drop the provSearchDelay back down to 1 second if you'd like. You're right, it's an analog of findProvsDelay.

@hannahhoward hannahhoward force-pushed the feat/connect-providers-in-sessions branch from ce2e171 to 6f7a77e Compare January 11, 2019 23:33
@hannahhoward hannahhoward merged commit fa9aec8 into master Jan 11, 2019
@ghost ghost removed the status/in-progress In progress label Jan 11, 2019
Jorropo pushed a commit to Jorropo/go-libipfs that referenced this pull request Jan 26, 2023
…s-in-sessions

fix(sessions): explicitly connect found peers

This commit was moved from ipfs/go-bitswap@fa9aec8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actually connect to providers in sessions
2 participants