get itersearch to run in the sim

This commit is contained in:
Arceliar 2018-06-02 00:16:47 -05:00
parent ecf7e490d7
commit 10a72444e3
3 changed files with 14 additions and 15 deletions

View File

@ -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)
//*

View File

@ -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()
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -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