mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
some minor refactoring to dht callbacks and searches, work in progress
This commit is contained in:
parent
2fd3ac6837
commit
29a0f8b572
4 changed files with 61 additions and 58 deletions
|
@ -517,21 +517,14 @@ func (c *Core) DHTPing(keyString, coordString, targetString string) (DHTRes, err
|
|||
rq := dhtReqKey{info.key, target}
|
||||
sendPing := func() {
|
||||
c.dht.addCallback(&rq, func(res *dhtRes) {
|
||||
defer func() { recover() }()
|
||||
select {
|
||||
case resCh <- res:
|
||||
default:
|
||||
}
|
||||
resCh <- res
|
||||
})
|
||||
c.dht.ping(&info, &target)
|
||||
}
|
||||
c.router.doAdmin(sendPing)
|
||||
go func() {
|
||||
time.Sleep(6 * time.Second)
|
||||
close(resCh)
|
||||
}()
|
||||
// TODO: do something better than the below...
|
||||
for res := range resCh {
|
||||
res := <-resCh
|
||||
if res != nil {
|
||||
r := DHTRes{
|
||||
Coords: append([]byte{}, res.Coords...),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue