Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close peerstore and document Host Close #1037

Merged
merged 2 commits into from
Jan 19, 2021
Merged

Conversation

aarshkshah1992
Copy link
Contributor

For #1030.

@MichaelMure
Copy link

LGTM 👍

@aarshkshah1992
Copy link
Contributor Author

ping @Stebalien

@@ -52,7 +52,7 @@ func ChainOptions(opts ...Option) Option {
// - If no peerstore is provided, the host is initialized with an empty
// peerstore.
//
// Canceling the passed context will stop the returned libp2p node.
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only correct order to call these actions? What happens if we call Close before we cancel the context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raulk The order is NOT important. I've updated the PR.

@aarshkshah1992
Copy link
Contributor Author

ping @Stebalien @raulk for approval.

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.

I seem to remember that we did it this way because we don't "own" the peerstore, it may be shared. However, closing this is probably strictly better than what we currently do.

Nit: I'd use:

if pstore := h.Peerstore(); pstore != nil {
    pstore.Close()
}

@aarshkshah1992 aarshkshah1992 merged commit 890f2e8 into master Jan 19, 2021
@aarshkshah1992 aarshkshah1992 deleted the feat/close-peerstore branch January 19, 2021 05:27
@Stebalien Stebalien mentioned this pull request May 11, 2021
27 tasks
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants