In your first terminal, start a seed node that has the complete file:
npm start -- --port 6881 --file test.txt
You should see output like:
Nodo P2P iniciado. ID: ab12cd34ef56, escuchando en puerto 6881.Archivo disponible para compartir: "test.txt" (27 bytes). Esperando conexiones de pares...
The seed node calculates the SHA-1 hash of the file automatically. This hash will be used to verify file integrity after download.
3
Start the leecher node
In a second terminal, start a leecher node that will download the file:
Conectando con peer inicial 127.0.0.1:6881...Meta de archivo recibida: "test.txt" (27 bytes, 1 piezas). Iniciando descarga...Pieza 0 recibida (27 bytes). Piezas restantes: 0.¡Descarga completada! Archivo "test.txt" descargado completamente.Verificación de integridad: OK (hash coincide).El nodo continuará corriendo como seed para compartir el archivo con otros peers.
Once the download completes, the leecher automatically becomes a seed and can share the file with other peers.
4
Verify the downloaded file
Check that the file was downloaded correctly:
cat test-downloaded.txt
The content should match your original file exactly.
For larger files, you’ll see more detailed progress tracking:
npm start -- --port 6881 --file large-video.mp4
Seed output:
Nodo P2P iniciado. ID: ef78cd90ab12, escuchando en puerto 6881.Archivo disponible para compartir: "large-video.mp4" (157286400 bytes). Esperando conexiones de pares...