-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 PR #25
Merged
DHT PR #25
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
61f13ea
begin planning of identification process
8d98d4b
making connections between nodes get closer to working
whyrusleeping 92fb51d
finish basic communcations between nodes and add a test of the ping o…
31dc65b
clean up after listeners on shutdown
whyrusleeping 35a4086
rough kbucket implementation, tests and cleanup to follow
whyrusleeping bade1aa
tests for kbucket and some code cleanup
whyrusleeping a85ce3f
finish implementation of Put and Get for DHT
whyrusleeping 248e06f
working towards Providers implementation
whyrusleeping 3a76ef0
a little error handling and some work on providers
whyrusleeping 71c7c58
providers interface is coming along nicely
whyrusleeping dc451fb
implement find peer rpc
whyrusleeping bd9fc2b
fix bug in routing table lookups
whyrusleeping 41c124a
worked on gathering data for diagnostic messages and some other misc …
whyrusleeping c22b6aa
fixing some race conditions
whyrusleeping 01ca93b
fixed small bug introduced during race condition frustration
whyrusleeping 24bfbfe
implement timeouts on listeners for the dht and add diagnostic stuff
whyrusleeping e14fb56
add a unit test for provides functionality
whyrusleeping ae6285e
address issues from code review (issue #25)
whyrusleeping 1eaeb3b
make tests pass a little more reliably by changing a port to not overlap
whyrusleeping 9f76043
moved routing table code into its own package
whyrusleeping 67ddab1
tiered put/get implemented
whyrusleeping a438862
more work implementing coral type lookups
whyrusleeping 0a41abd
starting a new testing framework
whyrusleeping 4cb2e1e
add fauxNet to stand in for Swarm in tests to reproduce various netwo…
whyrusleeping f09dba7
more tests and add in table filtering by peer latency
whyrusleeping b8a6fbb
modify use of swarm to not make duplicate connections
whyrusleeping 8542380
not quite working yet, but closer
whyrusleeping 60d061c
fix a few infinitely looping RPCs
whyrusleeping b7a882b
get implementation according to kademlia spec.
whyrusleeping 8a1fdbb
rewrite message response listening framework
whyrusleeping File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// The identify package handles how peers identify with eachother upon | ||
// connection to the network | ||
package identify | ||
|
||
import ( | ||
peer "github.com/jbenet/go-ipfs/peer" | ||
u "github.com/jbenet/go-ipfs/util" | ||
) | ||
|
||
// Perform initial communication with this peer to share node ID's and | ||
// initiate communication | ||
func Handshake(self, remote *peer.Peer, in, out chan []byte) error { | ||
// TODO: make this more... secure. | ||
out <- self.ID | ||
resp := <-in | ||
remote.ID = peer.ID(resp) | ||
u.DOut("[%s] identify: Got node id: %s", self.ID.Pretty(), remote.ID.Pretty()) | ||
|
||
return nil | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
message Identify { | ||
required bytes id = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package dht | ||
|
||
import ( | ||
peer "github.com/jbenet/go-ipfs/peer" | ||
) | ||
|
||
// A helper struct to make working with protbuf types easier | ||
type DHTMessage struct { | ||
Type PBDHTMessage_MessageType | ||
Key string | ||
Value []byte | ||
Response bool | ||
Id uint64 | ||
Success bool | ||
Peers []*peer.Peer | ||
} | ||
|
||
func peerInfo(p *peer.Peer) *PBDHTMessage_PBPeer { | ||
pbp := new(PBDHTMessage_PBPeer) | ||
addr, err := p.Addresses[0].String() | ||
if err != nil { | ||
//Temp: what situations could cause this? | ||
panic(err) | ||
} | ||
pbp.Addr = &addr | ||
pid := string(p.ID) | ||
pbp.Id = &pid | ||
return pbp | ||
} | ||
|
||
// TODO: building the protobuf message this way is a little wasteful | ||
// Unused fields wont be omitted, find a better way to do this | ||
func (m *DHTMessage) ToProtobuf() *PBDHTMessage { | ||
pmes := new(PBDHTMessage) | ||
if m.Value != nil { | ||
pmes.Value = m.Value | ||
} | ||
|
||
pmes.Type = &m.Type | ||
pmes.Key = &m.Key | ||
pmes.Response = &m.Response | ||
pmes.Id = &m.Id | ||
pmes.Success = &m.Success | ||
for _, p := range m.Peers { | ||
pmes.Peers = append(pmes.Peers, peerInfo(p)) | ||
} | ||
|
||
return pmes | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the
identify
pkg could also include aPublicKey
func that requests the remote peer's pub key. Handshake could do it if the key's not known locally yet. (RTT lost, prob worth sending along with the id).