Show HN: I built a concurrent BitTorrent engine in Go to master P2P protocols
Jyotishmoy Saturday, February 14, 2026I’ve always used BitTorrent, but I never understood the complexity of peer-to-peer orchestration until I tried to build it from scratch. I wanted to move beyond simple "Hello World" projects and tackle something that involved real-world constraints: network latency, data poisoning, and the "Slow Peer Problem."
Key Technical Challenges I Solved:
Non-Blocking Concurrency: Used a worker pool where each peer gets its own Goroutine. I implemented a "Stateless Worker" logic where if a peer fails a SHA-1 hash check or drops the connection, the piece is automatically re-queued into a thread-safe channel for other peers to pick up.
Request Pipelining: To fight network RTT, I implemented a pipeline depth of 5. The client dispatches multiple 16KB block requests without waiting for the previous one to return, ensuring the bandwidth is fully saturated.
The Binary Boundary: Dealing with Big-Endian logic and the 68-byte binary handshake taught me more about encoding/binary and byte-alignment than any textbook could.
Zero-Trust Data Integrity: Every 256KB piece is verified against a "Golden Hash" using crypto/sha1 before being written to disk. If a single bit is off, the data is purged.
The Specification: I’ve documented the full spec in the README, covering:
Reflection-based Bencode Parsing.
Compact Tracker Discovery (BEP-0023).
The Choke/Unchoke Protocol State Machine.
Data Granularity (Pieces vs. Blocks).
Repo: https://github.com/Jyotishmoy12/Bittorrent-Client-in-Go
I’d love to get feedback from the community on my concurrency model and how I handled the peer lifecycle.