Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Extract service implementation #2

Merged
merged 8 commits into from
Oct 18, 2018
Merged

Extract service implementation #2

merged 8 commits into from
Oct 18, 2018

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Oct 16, 2018

Extract the service implementation from the package, so that there is no dependency on go-libp2p; this allows us to import the package in go-libp2p itself.
The service implementation will live in https://github.com/libp2p/go-libp2p-autonat-svc.
Also extracts IsPublicAddr to go-multiaddr-net.

@ghost ghost assigned vyzo Oct 16, 2018
@ghost ghost added the status/in-progress In progress label Oct 16, 2018
@vyzo vyzo requested a review from Stebalien October 16, 2018 12:05
@vyzo vyzo mentioned this pull request Oct 17, 2018
8 tasks
@Stebalien
Copy link
Member

I'm going to apply my "someone else reviews this first" OKR (unless this is really burning).

@vyzo
Copy link
Contributor Author

vyzo commented Oct 18, 2018

we will need it to merge autorelay.

Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Few nits

autonat.go Outdated Show resolved Hide resolved

return h, a
}

// Note: these tests assume the host has only private inet addresses!
func connect(t *testing.T, a, b host.Host) {
pinfo := pstore.PeerInfo{ID: a.ID(), Addrs: a.Addrs()}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should move the PeerInfo struct to somewhere more common. It's a pity to have to import peerstore as a client, even if you don't intend to use the peerstore itself.

Added a note about this: https://github.com/libp2p/go-libp2p-peerstore/issues/35.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, this gets to me every single time as peerstore is a pretty big dependency.
Maybe we should have it in go-libp2p-peer?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. I think host is a better place as peer doesn't depend on multiaddrs. Noted for the (hopefully near) future.

autonat.go Outdated
func NewAutoNAT(ctx context.Context, h host.Host) AutoNAT {
func NewAutoNAT(ctx context.Context, h host.Host, ga ...GetAddrs) AutoNAT {
getAddrs := h.Addrs
if len(ga) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we decided against the customary Option approach? I prefer that approach, as this appears very limiting in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

turned into static argument per Magik's suggestion.

client.go Outdated
func NewAutoNATClient(h host.Host, ga ...GetAddrs) AutoNATClient {
getAddrs := h.Addrs
if len(ga) > 0 {
getAddrs = ga[0]
Copy link
Member

Choose a reason for hiding this comment

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

Could we get test coverage for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's covered in libp2p/go-libp2p-autonat-svc#1 which has an actual service implementation.
It's also implicitly covered in autonat_test which uses it internally.

@vyzo vyzo merged commit d7dc080 into master Oct 18, 2018
@ghost ghost removed the status/in-progress In progress label Oct 18, 2018
@vyzo vyzo deleted the feat/extract-svc branch October 18, 2018 15:17
willscott pushed a commit that referenced this pull request Mar 13, 2020
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.

4 participants