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

dht find connected peers #428

Merged
merged 11 commits into from
Dec 9, 2014
Merged

dht find connected peers #428

merged 11 commits into from
Dec 9, 2014

Conversation

jbenet
Copy link
Member

@jbenet jbenet commented Dec 9, 2014

This PR extends the DHT to send information re: peer "connectedness".
This means that --upon resolving dht queries -- connected peers will
signal whether or not they are directly connected to the peer. this is
in preparation for mesh messaging, and our "STUN" for NAT traversal.

@jbenet jbenet added the status/in-progress In progress label Dec 9, 2014
@jbenet
Copy link
Member Author

jbenet commented Dec 9, 2014

@whyrusleeping @maybebtc RFCR


const (
// NotConnected means no connection to peer, and no extra information (default)
NotConnected Connectedness = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

minor thing but you can use iota to enumerate

const (
  Not Connectedness = iota
  Connected
  Can
  Cannot
)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, i wanted to be explicit here to make sure it matches Message_ConnectionType_value. This may not be the best idea, perhaps i should import those symbols.

Copy link
Member Author

Choose a reason for hiding this comment

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

may not need it, given the functions: https://github.com/jbenet/go-ipfs/pull/428/files#diff-d7b3509b9fcd5fce42069cf169ede81eR142

do you care much either way?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah. functions like those are kosher 👍

given the existence of those functions, i don't see a reason to rely on the enum value to provide a mapping between the types. iota seems like an all-around better deal.

but it's really not a big deal. i don't forsee a bug being introduced due to the decision. 🌲 ✊ : 🌲

Looking at the big picture, where would you want me to focus CR attention? Is there anything particular you're concerned about?

(It's easy to get lost in syntax)

Copy link
Member Author

Choose a reason for hiding this comment

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

but it's really not a big deal. i don't forsee a bug being introduced due to the decision.

agreed. same here, i think this was a vestige from before those funcs. addressed in 93872a5

Looking at the big picture, where would you want me to focus CR attention? Is there anything particular you're concerned about?

Mostly the notion of "connectedness" and DHT logic. the added dht query https://github.com/jbenet/go-ipfs/pull/428/files#diff-b4153ad02ca247a808e7a06fd1e2f133R272 -- it's mostly the same as the others, with small tweaks

// FindPeersConnectedToPeer searches for peers directly connected to a given peer.
func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<-chan peer.Peer, error) {

peerchan := make(chan peer.Peer, 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

minor but

Perhaps we should start extracting these chanbuffer constants so we preserve information that went into the decision to choose the particular value.

0 and 1 are obvious to the reader, but arbitrary c, I can never be sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. addressed in: 26a44fc

@btc
Copy link
Contributor

btc commented Dec 9, 2014

LGTM

jbenet added a commit that referenced this pull request Dec 9, 2014
@jbenet jbenet merged commit d74ea44 into master Dec 9, 2014
@jbenet jbenet removed the status/in-progress In progress label Dec 9, 2014
@jbenet jbenet deleted the dht-connected-peers branch December 9, 2014 06:05
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Oct 23, 2021
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.

2 participants