Skip to content

Commit

Permalink
refactor(p2p): rename minTrustedHeadResponses to minHeadResponses
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Jun 27, 2023
1 parent cb15015 commit 33ff9b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions p2p/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (

var log = logging.Logger("header/p2p")

// minTrustedHeadResponses is the minimum number of headers of the same height
// received from trusted peers to determine the network head. If all trusted
// header will return headers with non-equal height, then the highest header will be chosen.
const minTrustedHeadResponses = 2
// minHeadResponses is the minimum number of headers of the same height
// received from peers to determine the network head. If all trusted peers
// will return headers with non-equal height, then the highest header will be
// chosen.
const minHeadResponses = 2

// minUntrustedHeadRequests is the minimum number of head requests to be made to
// the network in order to determine the network head.
Expand Down Expand Up @@ -362,7 +363,7 @@ func bestHead[H header.Header](result []H) (H, error) {

// try to find Header with the maximum height that was received at least from 2 peers
for _, res := range result {
if counter[res.Hash().String()] >= minTrustedHeadResponses {
if counter[res.Hash().String()] >= minHeadResponses {
return res, nil
}
}
Expand Down
3 changes: 1 addition & 2 deletions p2p/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestExchange_RequestHead(t *testing.T) {
require.NoError(t, err)
})

var tests = []struct {
tests := []struct {
withSubjInit bool
expectedHeight int64
expectedHash header.Hash
Expand Down Expand Up @@ -85,7 +85,6 @@ func TestExchange_RequestHead(t *testing.T) {

assert.Equal(t, tt.expectedHeight, header.Height())
assert.Equal(t, tt.expectedHash, header.Hash())

})
}
}
Expand Down

0 comments on commit 33ff9b1

Please sign in to comment.