mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	value instead of pointer types for search dest/mask
This commit is contained in:
		
							parent
							
								
									34939d4b18
								
							
						
					
					
						commit
						45abfafbba
					
				
					 1 changed files with 8 additions and 8 deletions
				
			
		| 
						 | 
					@ -25,8 +25,8 @@ const search_MAX_SEARCH_SIZE = 16
 | 
				
			||||||
const search_RETRY_TIME = time.Second
 | 
					const search_RETRY_TIME = time.Second
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type searchInfo struct {
 | 
					type searchInfo struct {
 | 
				
			||||||
	dest    *NodeID
 | 
						dest    NodeID
 | 
				
			||||||
	mask    *NodeID
 | 
						mask    NodeID
 | 
				
			||||||
	time    time.Time
 | 
						time    time.Time
 | 
				
			||||||
	packet  []byte
 | 
						packet  []byte
 | 
				
			||||||
	toVisit []*dhtInfo
 | 
						toVisit []*dhtInfo
 | 
				
			||||||
| 
						 | 
					@ -51,8 +51,8 @@ func (s *searches) createSearch(dest *NodeID, mask *NodeID) *searchInfo {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info := searchInfo{
 | 
						info := searchInfo{
 | 
				
			||||||
		dest: dest,
 | 
							dest: *dest,
 | 
				
			||||||
		mask: mask,
 | 
							mask: *mask,
 | 
				
			||||||
		time: now.Add(-time.Second),
 | 
							time: now.Add(-time.Second),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	s.searches[*dest] = &info
 | 
						s.searches[*dest] = &info
 | 
				
			||||||
| 
						 | 
					@ -106,13 +106,13 @@ func (s *searches) addToSearch(sinfo *searchInfo, res *dhtRes) {
 | 
				
			||||||
func (s *searches) doSearchStep(sinfo *searchInfo) {
 | 
					func (s *searches) doSearchStep(sinfo *searchInfo) {
 | 
				
			||||||
	if len(sinfo.toVisit) == 0 {
 | 
						if len(sinfo.toVisit) == 0 {
 | 
				
			||||||
		// Dead end, do cleanup
 | 
							// Dead end, do cleanup
 | 
				
			||||||
		delete(s.searches, *sinfo.dest)
 | 
							delete(s.searches, sinfo.dest)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// Send to the next search target
 | 
							// Send to the next search target
 | 
				
			||||||
		var next *dhtInfo
 | 
							var next *dhtInfo
 | 
				
			||||||
		next, sinfo.toVisit = sinfo.toVisit[0], sinfo.toVisit[1:]
 | 
							next, sinfo.toVisit = sinfo.toVisit[0], sinfo.toVisit[1:]
 | 
				
			||||||
		s.core.dht.ping(next, sinfo.dest)
 | 
							s.core.dht.ping(next, &sinfo.dest)
 | 
				
			||||||
		sinfo.visited[*next.getNodeID()] = true
 | 
							sinfo.visited[*next.getNodeID()] = true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -127,7 +127,7 @@ func (s *searches) continueSearch(sinfo *searchInfo) {
 | 
				
			||||||
	// Note that this will spawn multiple parallel searches as time passes
 | 
						// Note that this will spawn multiple parallel searches as time passes
 | 
				
			||||||
	// Any that die aren't restarted, but a new one will start later
 | 
						// Any that die aren't restarted, but a new one will start later
 | 
				
			||||||
	retryLater := func() {
 | 
						retryLater := func() {
 | 
				
			||||||
		newSearchInfo := s.searches[*sinfo.dest]
 | 
							newSearchInfo := s.searches[sinfo.dest]
 | 
				
			||||||
		if newSearchInfo != sinfo {
 | 
							if newSearchInfo != sinfo {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -199,7 +199,7 @@ func (s *searches) sendSearch(info *searchInfo) {
 | 
				
			||||||
	req := searchReq{
 | 
						req := searchReq{
 | 
				
			||||||
		key:    s.core.boxPub,
 | 
							key:    s.core.boxPub,
 | 
				
			||||||
		coords: coords,
 | 
							coords: coords,
 | 
				
			||||||
		dest:   *info.dest,
 | 
							dest:   info.dest,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info.time = time.Now()
 | 
						info.time = time.Now()
 | 
				
			||||||
	s.handleSearchReq(&req)
 | 
						s.handleSearchReq(&req)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue