How eliasson/pieces works
pieces is an experimental asyncio BitTorrent download client. A user supplies a single-file .torrent through the CLI; metadata is parsed, the client periodically announces to a tracker, queues returned peers, and coordinates peer connections that request blocks. The piece manager assembles and verifies pieces before writing them to disk and the client stops when complete. The README documents this workflow and the message/stream design; unsampled source limits detail about some runtime calls.
Main entry points: protocol.py Peer connection · client.py Download coordinator · tracker.py Tracker announce · cli.py Command-line entry
Components 14
Entry and metadata
- Command-line entry
pieces/cli.py - Torrent metadata
pieces/torrent.py
Download coordination
- Download coordinator
pieces/client.py - Tracker announce
pieces/tracker.py - Available-peer queue
pieces/client.py - Piece scheduling and assembly
pieces/client.py - Downloaded file
BitTorrent protocol
- Peer connection
pieces/protocol.py - Peer message stream
pieces/protocol.py - Peer message codecs
pieces/protocol.py
Metadata encoding
- Bencode codec
pieces/bencoding.py
Other components
- User
- Tracker
- Remote peers
Connections 17
- User → Command-line entry: starts download
README.md - Command-line entry → Torrent metadata: loads metadata
pieces/cli.py - Command-line entry → Download coordinator: starts client
pieces/cli.py - Torrent metadata → Bencode codec: decodes metadata
pieces/torrent.py - Tracker announce → Bencode codec: decodes response
pieces/tracker.py - Download coordinator → Tracker announce: announces periodically
pieces/client.py - Tracker announce → Tracker: requests peers
pieces/tracker.py - Tracker → Tracker announce: returns peers
- Download coordinator → Available-peer queue: enqueues peers
pieces/client.py - Download coordinator → Piece scheduling and assembly: coordinates pieces
pieces/client.py - Download coordinator → Peer connection: starts workers
README.md - Peer connection → Available-peer queue: consumes peers
pieces/protocol.py - Peer connection → Remote peers: connects to
pieces/protocol.py - Peer connection → Peer message stream: reads messages
pieces/protocol.py - Peer connection → Peer message codecs: encodes messages
pieces/protocol.py - Peer connection → Piece scheduling and assembly: requests blocks
README.md - Piece scheduling and assembly → Downloaded file: writes verified pieces
pieces/client.py