How to Use
P2PNetwork currently has three entrypoints in Network/cmd:
bootstrap- interactive bootstrap nodepeer- interactive peer nodegui- Fyne desktop UI
Build the binaries
Section titled “Build the binaries”From Network/:
go build -o bootstrap ./cmd/bootstrapgo build -o peer ./cmd/peergo build -o gui ./cmd/guiThe repository also includes a Makefile:
make bootstrapmake peerBootstrap node flow
Section titled “Bootstrap node flow”Start the bootstrap node:
./bootstrapThe program prompts for a node name, appends -bootstrap to it, starts on port 52837, prints the peer ID and multiaddrs, and writes the first multiaddr to a file called bs-nodes in the working directory.
Keep this terminal open. Every peer needs a bootstrap address to start discovering the network.
Peer node flow
Section titled “Peer node flow”Start a second terminal in the same directory:
./peerThe peer node:
- reads
bs-nodesif it exists - prompts for a display name
- connects to the bootstrap peers
- starts discovery on
fgov-network - keeps reconnecting to discovered peers when they are not already connected
Commands in the peer CLI
Section titled “Commands in the peer CLI”The peer terminal accepts these commands:
connect <multiaddr>peersdiscoveredexitNotes:
connectexpects a full/ip4/.../tcp/.../p2p/...multiaddrpeersprints the currently connected peers and their namesdiscoveredprints peers found by discoveryexitshuts the node down cleanly
The current CLI does not expose a disconnect command, even though the node package has a Disconnect method for programmatic use.
GUI flow
Section titled “GUI flow”Run the desktop app:
./guiThe window title is FGov P2P Network. It lets you:
- enter a node name
- turn the node on and off
- refresh the peer list
- inspect the current running state
What the network does on startup
Section titled “What the network does on startup”- The host is created with libp2p.
- The DHT starts in server mode.
- Bootstrap peers from
bs-nodesare connected. - The node prints
Peer IDandFull addresses. - Discovery starts after a short delay.
- Connected peers exchange names over the
/fgovprotocol.
Working with bs-nodes
Section titled “Working with bs-nodes”The bootstrap node writes the first multiaddr it sees to bs-nodes.
That means:
- running the peer from the same directory is enough for local testing
- copying
bs-nodesto another machine lets another peer join the same bootstrap node - if you move the binary elsewhere, copy the file too
Practical examples
Section titled “Practical examples”Local test setup
Section titled “Local test setup”./bootstrap./peer./peerBecause peer nodes listen on port 0, they pick an available port automatically. You can run several on one machine without adding a custom port flag.
Join from another machine
Section titled “Join from another machine”- Start the bootstrap node on a reachable host.
- Use the printed multiaddr with the host’s real IP address.
- Give that multiaddr to peers on the same network or across the internet.
Troubleshooting
Section titled “Troubleshooting”The peer never finds anything
Section titled “The peer never finds anything”- Check that
bs-nodesexists - Check that the bootstrap node is still running
- Make sure the printed multiaddr uses an address the peer can actually reach
The GUI starts but shows no peers
Section titled “The GUI starts but shows no peers”- Make sure a bootstrap node is already running
- Refresh after the peer has had time to discover others
The name output looks odd
Section titled “The name output looks odd”- The bootstrap node gets
-bootstrapappended automatically - Names are exchanged directly between peers after a connection is established
Next pages
Section titled “Next pages”- Services - bootstrap, discovery, and name sync behavior
- Network Protocol - the actual topics and stream handlers
- Deployment - how to run this outside local testing