-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Devp2p Improvements and Clean-Ups / Client ID Integration (#2538)
* devp2p: added singlePeerRun.ts script, new script folder setup structure * devp2p: removed outdated Parity DPT server ping response hack * devp2p: improved RLPx HELLO message logging (added protocol version and client ID) * Client: use client version for RLPx initialization * Minor
- Loading branch information
Showing
6 changed files
with
57 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { randomBytes } from 'crypto' | ||
import { Chain, Common } from '@ethereumjs/common' | ||
import * as devp2p from '../src/index' | ||
|
||
const PEER_ADDRESS = '[ADD_REMOTE_PEER_IP]' | ||
const PEER_PORT = 30303 | ||
const ETH_PROTOCOL = devp2p.ETH.eth66 | ||
|
||
const PRIVATE_KEY = randomBytes(32) | ||
|
||
const common = new Common({ chain: Chain.Sepolia }) | ||
|
||
const dpt = new devp2p.DPT(PRIVATE_KEY, { | ||
refreshInterval: 30000, | ||
endpoint: { | ||
address: '0.0.0.0', | ||
udpPort: null, | ||
tcpPort: null, | ||
}, | ||
shouldFindNeighbours: false, | ||
shouldGetDnsPeers: false, | ||
}) | ||
|
||
const rlpx = new devp2p.RLPx(PRIVATE_KEY, { | ||
dpt, | ||
maxPeers: 1, | ||
capabilities: [ETH_PROTOCOL], | ||
common, | ||
}) | ||
|
||
const run = async () => { | ||
// Emits 'peer:new' on success, rlpx listens and | ||
// calls into `rlpx.connect | ||
await dpt.addPeer({ | ||
address: PEER_ADDRESS, | ||
udpPort: PEER_PORT, | ||
tcpPort: PEER_PORT, | ||
}) | ||
} | ||
|
||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters