Skip to content

Commit

Permalink
rename(p2p): rename minUntrustedHeadRequests -> numUntrustedHeadRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Jun 30, 2023
1 parent 33ff9b1 commit 60bda34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions p2p/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ var log = logging.Logger("header/p2p")
// chosen.
const minHeadResponses = 2

// minUntrustedHeadRequests is the minimum number of head requests to be made to
// numUntrustedHeadRequests is the number of head requests to be made to
// the network in order to determine the network head.
var minUntrustedHeadRequests = 4
var numUntrustedHeadRequests = 4

// Exchange enables sending outbound HeaderRequests to the network as well as
// handling inbound HeaderRequests from the network.
Expand Down Expand Up @@ -132,11 +132,11 @@ func (ex *Exchange[H]) Head(ctx context.Context, reqOpts ...RequestOption) (H, e
}

peers := ex.peerTracker.GetPeers()
if reqParams.SubjectiveInit || len(peers) < minUntrustedHeadRequests {
if reqParams.SubjectiveInit || len(peers) < numUntrustedHeadRequests {
peers = ex.trustedPeers()
} else {
// only query a subset
peers = peers[:minUntrustedHeadRequests]
peers = peers[:numUntrustedHeadRequests]
}

var (
Expand Down
2 changes: 1 addition & 1 deletion p2p/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestExchange_RequestHead(t *testing.T) {

// decrease the minimum number of untrusted peers to request head from
// for testing purposes
minUntrustedHeadRequests = 2
numUntrustedHeadRequests = 2

hosts := createMocknet(t, 3)
exchg, trustedStore := createP2PExAndServer(t, hosts[0], hosts[1])
Expand Down

0 comments on commit 60bda34

Please sign in to comment.