Lightweight BSC block listener. Joins the devp2p network as an eth/68 peer and prints new blocks.
go build -o bsc-p2p .
./bsc-p2p # just blocks
./bsc-p2p -v # + peer events, discovery
22:06:32 #91772632 19:06:32 0x4c76edd5…c37030a8 txs=74 gas=8409575/55000000 (15%) validator=0xbdcc…
22:06:34 #91772634 19:06:34 0x9caffea1…34fdb0a4 txs=84 gas=12867530/55000000 (23%) validator=0xbdcc…
22:06:35 #91772635 19:06:35 0xc6882564…6559ae04 txs=82 gas=12495516/55000000 (23%) validator=0xbdcc…
| Flag | Default | Description |
|---|---|---|
-rpc |
https://bsc-dataseed.bnbchain.org |
RPC for initial head fetch |
-port |
0 (auto) |
TCP/UDP listen port |
-bootnodes |
(official BSC) | Comma-separated enode URLs |
-v |
off | Verbose logging |
- Fetches current head from RPC (for Status handshake)
- Computes EIP-2124 ForkID from hardcoded BSC fork schedule
- Starts go-ethereum
p2p.Serverwith discv4 discovery - Handshakes eth/68 Status + BSC UpgradeStatus with each peer
- Prints NewBlock messages, drops stale blocks
Discovered peers are cached to ~/.cache/bsc-p2p/peers for fast reconnect.