mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 09:31:34 +00:00
get itersearch to run in the sim
This commit is contained in:
parent
ecf7e490d7
commit
10a72444e3
@ -413,10 +413,10 @@ func main() {
|
||||
}
|
||||
fmt.Println("Test")
|
||||
Util_testAddrIDMask()
|
||||
//idxstore := makeStoreSquareGrid(4)
|
||||
idxstore := makeStoreSquareGrid(4)
|
||||
//idxstore := makeStoreStar(256)
|
||||
//idxstore := loadGraph("misc/sim/hype-2016-09-19.list")
|
||||
idxstore := loadGraph("misc/sim/fc00-2017-08-12.txt")
|
||||
//idxstore := loadGraph("misc/sim/fc00-2017-08-12.txt")
|
||||
//idxstore := loadGraph("skitter")
|
||||
kstore := getKeyedStore(idxstore)
|
||||
//*
|
||||
|
@ -35,6 +35,8 @@ func (c *Core) Init() {
|
||||
bpub, bpriv := newBoxKeys()
|
||||
spub, spriv := newSigKeys()
|
||||
c.init(bpub, bpriv, spub, spriv)
|
||||
c.router.start()
|
||||
c.switchTable.start()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -58,18 +58,20 @@ func (s *searches) createSearch(dest *NodeID, mask *NodeID) *searchInfo {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
func (s *searches) handleDHTRes(res *dhtRes) {
|
||||
if s.checkDHTRes(res) {
|
||||
sinfo, isIn := s.searches[res.dest]
|
||||
if !isIn || s.checkDHTRes(sinfo, res) {
|
||||
// Either we don't recognize this search, or we just finished it
|
||||
return
|
||||
} else {
|
||||
// Add to the search and continue
|
||||
s.addToSearch(sinfo, res)
|
||||
s.doSearchStep(sinfo)
|
||||
}
|
||||
s.addToSearch(res)
|
||||
}
|
||||
|
||||
func (s *searches) addToSearch(res *dhtRes) {
|
||||
func (s *searches) addToSearch(sinfo *searchInfo, res *dhtRes) {
|
||||
// TODO
|
||||
sinfo, isIn := s.searches[res.dest]
|
||||
if !isIn {
|
||||
return
|
||||
}
|
||||
|
||||
from := dhtInfo{key: res.key, coords: res.coords}
|
||||
for _, info := range res.infos {
|
||||
if dht_firstCloserThanThird(info.getNodeID(), &res.dest, from.getNodeID()) {
|
||||
@ -79,7 +81,6 @@ func (s *searches) addToSearch(res *dhtRes) {
|
||||
sort.SliceStable(sinfo.toVisit, func(i, j int) bool {
|
||||
return dht_firstCloserThanThird(sinfo.toVisit[i].getNodeID(), &res.dest, sinfo.toVisit[j].getNodeID())
|
||||
})
|
||||
s.doSearchStep(sinfo)
|
||||
}
|
||||
|
||||
func (s *searches) doSearchStep(sinfo *searchInfo) {
|
||||
@ -109,11 +110,7 @@ func (s *searches) newIterSearch(dest *NodeID, mask *NodeID) *searchInfo {
|
||||
return sinfo
|
||||
}
|
||||
|
||||
func (s *searches) checkDHTRes(res *dhtRes) bool {
|
||||
info, isIn := s.searches[res.dest]
|
||||
if !isIn {
|
||||
return false
|
||||
}
|
||||
func (s *searches) checkDHTRes(info *searchInfo, res *dhtRes) bool {
|
||||
them := getNodeID(&res.key)
|
||||
var destMasked NodeID
|
||||
var themMasked NodeID
|
||||
|
Loading…
Reference in New Issue
Block a user