ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.18k stars 3.02k forks source link

DHT Refactoring #160

Closed whyrusleeping closed 10 years ago

whyrusleeping commented 10 years ago

As @jbenet is quick to mention, the DHT could use a bit more abstraction, this issue will be a place to discuss those changes.

whyrusleeping commented 10 years ago

We have a good number of methods that make a single one hop request to a single given peer, i have most of these methods suffixed with 'Single' but it would be nice to come up with a name that more clearly describes their purpose and refactor them to have a similar interface. and potentially put them all in their own file.

These methods are:

findProvidersSingle
findPeerSingle
getValueSingle
putValueToNetwork
whyrusleeping commented 10 years ago

The clustering idea needs to be abstracted out more, and some pleasant interface should be made. Maybe having a channel to read peers from would be the easiest interface to satisfy, then the object can automatically move to more distant peers as it runs out of closer ones.

whyrusleeping commented 10 years ago

@jbenet what do you think of having a peer type for the dht that contains context about routing levels? Something like a LeveledPeer, that (for coral type routing scenarios) contains information about which level of cluster its in

jbenet commented 10 years ago

All this sgtm. there's also a dht interface lying around somewhere in an issue (that both standard kademlia, coral, etc can implement for the general "routing-over-dht" dht/routing.go code.