mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Try using a chord-like DHT instead of a kad-like one, work in progress, but it compiles at least
This commit is contained in:
parent
a9f72a6ee1
commit
03a88fe304
7 changed files with 182 additions and 510 deletions
|
@ -554,26 +554,28 @@ func (a *admin) getData_getSwitchQueues() admin_nodeInfo {
|
|||
// getData_getDHT returns info from Core.dht for an admin response.
|
||||
func (a *admin) getData_getDHT() []admin_nodeInfo {
|
||||
var infos []admin_nodeInfo
|
||||
now := time.Now()
|
||||
getDHT := func() {
|
||||
for i := 0; i < a.core.dht.nBuckets(); i++ {
|
||||
b := a.core.dht.getBucket(i)
|
||||
getInfo := func(vs []*dhtInfo, isPeer bool) {
|
||||
for _, v := range vs {
|
||||
addr := *address_addrForNodeID(v.getNodeID())
|
||||
info := admin_nodeInfo{
|
||||
{"ip", net.IP(addr[:]).String()},
|
||||
{"coords", fmt.Sprint(v.coords)},
|
||||
{"bucket", i},
|
||||
{"peer_only", isPeer},
|
||||
{"last_seen", int(now.Sub(v.recv).Seconds())},
|
||||
/* TODO fix this
|
||||
now := time.Now()
|
||||
for i := 0; i < a.core.dht.nBuckets(); i++ {
|
||||
b := a.core.dht.getBucket(i)
|
||||
getInfo := func(vs []*dhtInfo, isPeer bool) {
|
||||
for _, v := range vs {
|
||||
addr := *address_addrForNodeID(v.getNodeID())
|
||||
info := admin_nodeInfo{
|
||||
{"ip", net.IP(addr[:]).String()},
|
||||
{"coords", fmt.Sprint(v.coords)},
|
||||
{"bucket", i},
|
||||
{"peer_only", isPeer},
|
||||
{"last_seen", int(now.Sub(v.recv).Seconds())},
|
||||
}
|
||||
infos = append(infos, info)
|
||||
}
|
||||
}
|
||||
infos = append(infos, info)
|
||||
getInfo(b.other, false)
|
||||
getInfo(b.peers, true)
|
||||
}
|
||||
}
|
||||
getInfo(b.other, false)
|
||||
getInfo(b.peers, true)
|
||||
}
|
||||
*/
|
||||
}
|
||||
a.core.router.doAdmin(getDHT)
|
||||
return infos
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue