Files
go-i2p/lib/netdb/kad.go
idk 0ec4f55fa9 Check in unchecked-in common library fixes, start implementing transports.
Since I turned out to be implementing parts of Noise which I did not need to implement, I'm taking a different approach, and doing an unmodified Noise transport first and then making our modifications to it. That should reduce what I need to do to message pre-processing mostly, I think.
2022-07-11 23:41:58 -04:00

35 lines
848 B
Go

package netdb
import (
"time"
common "github.com/go-i2p/go-i2p/lib/common/data"
"github.com/go-i2p/go-i2p/lib/common/router_info"
"github.com/go-i2p/go-i2p/lib/tunnel"
)
// 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 router_info.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
}