mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-10 11:16:37 -04:00

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.
35 lines
848 B
Go
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
|
|
}
|