Skip to content

Commit

Permalink
Eth65: Rename and stop exporting protocolVersion
Browse files Browse the repository at this point in the history
This constant shouldn't be used outside `protocol_eth65`.

When we support multiple `eth/NN` versions side by side, or even just have
multiple code files, there's a risk some code would import just one of the
files (e.g. `protocol_eth65`), use `protocolVersion`, and incorrectly act as
though that version is the one active on the node.

In fact that happened, and now it can't happen.  Other code needs to query the
`EtheruemNode` to find what versions are really active.

Signed-off-by: Jamie Lokier <[email protected]>
  • Loading branch information
jlokier committed Jul 27, 2021
1 parent 5ddfd7d commit 936a18b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nimbus/sync/protocol_eth65.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const
maxBodiesFetch* = 128
maxReceiptsFetch* = 256
maxHeadersFetch* = 192
protocolVersion* = 65
ethVersion = 65

func toHex(x: KeccakHash): string = x.data.toHex

p2pProtocol eth(version = protocolVersion,
p2pProtocol eth(version = ethVersion,
peerState = PeerState,
useRequestIds = false):

Expand All @@ -56,7 +56,7 @@ p2pProtocol eth(version = protocolVersion,
forkNext: chainForkId.nextFork.u256,
)

let m = await peer.status(protocolVersion,
let m = await peer.status(ethVersion,
network.networkId,
bestBlock.difficulty,
bestBlock.blockHash,
Expand All @@ -82,7 +82,7 @@ p2pProtocol eth(version = protocolVersion,
handshake:
# User message 0x00: Status.
proc status(peer: Peer,
protocolVersion: uint,
ethVersionArg: uint,
networkId: NetworkId,
totalDifficulty: DifficultyInt,
bestHash: KeccakHash,
Expand Down

0 comments on commit 936a18b

Please sign in to comment.