Skip to content

Implements parallel piece downloading from multiple peers. - #3

Merged
Achintya47 merged 10 commits into
mainfrom
parallel-download-feature
Aug 12, 2026
Merged

Achintya47 merged 10 commits into
mainfrom
parallel-download-feature

Conversation

@Achintya47

Copy link
Copy Markdown
Owner

This PR extends tnerroT from tracker communication and peer discovery to actual data transfer. Introduces peer communication which involves proper handshakes, maintaining peer state machine, and proper communication. Apart from that, thread dispatchable downloader has been implemented with a simple concurrency model. Piece Manager maintains the piece states as Missing, Complete or In-Progress and Logging functionality for network and downloading activities.

What Changed

Peer Management

  • Added peer.c / peer.h
  • Implemented BitTorrent peer handshake
  • Added peer connection management
  • Added peer message parsing/framing
  • Handles peer availability/bitfield information
  • Supports multiple simultaneous peer connections

Download Manager

  • Added downloader.c / downloader.h
  • Coordinates multiple peer connections
  • Assigns pieces/blocks to available peers
  • Tracks download progress
  • Handles completed and failed requests

Piece Management

  • Added piece_manager.c / piece_manager.h
  • Tracks piece state
  • Prevents multiple peers from unnecessarily downloading the same work
  • Tracks requested/completed pieces
  • Performs piece-level SHA-1 verification

File Writer

  • Added file_writer.c / file_writer.h
  • Writes completed pieces directly to their correct file offsets
  • Avoids keeping the entire torrent payload in memory
  • Supports random-access writes for out-of-order piece completion

Logging

  • Added log.c / log.h
  • Centralized logging functionality
  • Provides consistent logging across peer, downloader, and storage
    components

@Achintya47
Achintya47 merged commit 07566ec into main Aug 12, 2026
1 check failed
@Achintya47
Achintya47 deleted the parallel-download-feature branch August 12, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant