mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-16 05:44:45 -04:00
33 lines
779 B
Go
33 lines
779 B
Go
package netdb
|
|
|
|
import (
|
|
"github.com/go-i2p/go-i2p/lib/common"
|
|
"github.com/go-i2p/go-i2p/lib/tunnel"
|
|
"time"
|
|
)
|
|
|
|
// resolves router infos with recursive kademlia lookup
|
|
type kadResolver struct {
|
|
// netdb to store result into
|
|
netDB NetworkDatabase
|
|
// what tunnel pool to use when doing lookup
|
|
// if nil the lookup will be done directly
|
|
pool *tunnel.Pool
|
|
}
|
|
|
|
// TODO: implement
|
|
func (kr *kadResolver) Lookup(h common.Hash, timeout time.Duration) (chnl chan common.RouterInfo) {
|
|
return
|
|
}
|
|
|
|
// create a new resolver that stores result into a NetworkDatabase and uses a tunnel pool for the lookup
|
|
func KademliaResolver(netDb NetworkDatabase, pool *tunnel.Pool) (r Resolver) {
|
|
if pool != nil && netDb != nil {
|
|
r = &kadResolver{
|
|
netDB: netDb,
|
|
pool: pool,
|
|
}
|
|
}
|
|
return
|
|
}
|