Skip to content

nikicat/bsc-p2p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bsc-p2p

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…

Flags

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

How it works

  1. Fetches current head from RPC (for Status handshake)
  2. Computes EIP-2124 ForkID from hardcoded BSC fork schedule
  3. Starts go-ethereum p2p.Server with discv4 discovery
  4. Handshakes eth/68 Status + BSC UpgradeStatus with each peer
  5. Prints NewBlock messages, drops stale blocks

Discovered peers are cached to ~/.cache/bsc-p2p/peers for fast reconnect.

About

Lightweight BSC block listener. Joins the devp2p network as an eth/68 peer and prints new blocks.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages