Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Mar 23, 2020
1 parent 0a01437 commit 72cd036
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type query struct {
}

type lookupResult struct {
peers []peer.ID
state []qpeerset.PeerState
peers []peer.ID
state []qpeerset.PeerState
completed bool
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func (dht *IpfsDHT) runLookup(ctx context.Context, d int, target string, queryFn
}

// return if the lookup has been externally stopped
if ctx.Err() != nil || stopFn() {
if ctx.Err() != nil || stopFn() {
lookupRes.completed = false
return lookupRes, nil
}
Expand All @@ -100,23 +100,22 @@ func (dht *IpfsDHT) runLookup(ctx context.Context, d int, target string, queryFn
}

// wait for all queries to complete before returning, aborting ongoing queries if we've been externally stopped
processFollowUp:
for i := 0; i < len(queryPeers); i++ {
select{
case <-doneCh:
if stopFn() {
cancelFollowUp()
if i < len(queryPeers) - 1 {
lookupRes.completed = false
}
break processFollowUp
processFollowUp:
for i := 0; i < len(queryPeers); i++ {
select {
case <-doneCh:
if stopFn() {
cancelFollowUp()
if i < len(queryPeers)-1 {
lookupRes.completed = false
}
case <-ctx.Done():
lookupRes.completed = false
break processFollowUp
}
case <-ctx.Done():
lookupRes.completed = false
break processFollowUp
}

}

return lookupRes, nil
}
Expand Down Expand Up @@ -196,7 +195,7 @@ func (dht *IpfsDHT) constructLookupResult(queries []*query, target kb.ID) *looku
// determine if any queries terminated early
completed := true
for _, q := range queries {
if !(q.isLookupTermination() || q.isStarvationTermination()){
if !(q.isLookupTermination() || q.isStarvationTermination()) {
completed = false
break
}
Expand Down
2 changes: 1 addition & 1 deletion routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ peer.AddrInfo,
break
}
}
if discoveredPeerDuringQuery || lookupRes.completed{
if discoveredPeerDuringQuery || lookupRes.completed {
dht.routingTable.ResetCplRefreshedAtForID(kb.ConvertPeerID(id), time.Now())
}
}
Expand Down

0 comments on commit 72cd036

Please sign in to comment.