Add logging to debug why the download doesnt progress when deployed to dokku
This commit is contained in:
@@ -212,6 +212,7 @@ export class TorrentSession {
|
|||||||
const actualHash = crypto.createHash('sha1').update(fullPiece).digest();
|
const actualHash = crypto.createHash('sha1').update(fullPiece).digest();
|
||||||
|
|
||||||
if (expectedHash && Buffer.compare(actualHash, expectedHash) === 0) {
|
if (expectedHash && Buffer.compare(actualHash, expectedHash) === 0) {
|
||||||
|
console.log(`[Engine] Piece ${index} VERIFIED! Progress: ${this.progress}%`);
|
||||||
this.bitfield.set(index);
|
this.bitfield.set(index);
|
||||||
this.storage?.writePiece(index, this.pieceLength, fullPiece);
|
this.storage?.writePiece(index, this.pieceLength, fullPiece);
|
||||||
this.reassemblers.delete(index);
|
this.reassemblers.delete(index);
|
||||||
@@ -224,7 +225,9 @@ export class TorrentSession {
|
|||||||
console.log(`[Engine] Torrent ${this.hash} download COMPLETED!`);
|
console.log(`[Engine] Torrent ${this.hash} download COMPLETED!`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Hash failed, restart piece
|
const expectedHex = expectedHash ? Buffer.from(expectedHash).toString('hex').slice(0, 8) : 'unknown';
|
||||||
|
const actualHex = actualHash.toString('hex').slice(0, 8);
|
||||||
|
console.error(`[Engine] Piece ${index} Hash Mismatch! Expected ${expectedHex}... Got ${actualHex}...`);
|
||||||
this.reassemblers.delete(index);
|
this.reassemblers.delete(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export class PeerWorker {
|
|||||||
const begin = payload.readUInt32BE(4);
|
const begin = payload.readUInt32BE(4);
|
||||||
const block = payload.slice(8);
|
const block = payload.slice(8);
|
||||||
this.pendingRequests.delete(`${index}:${begin}`);
|
this.pendingRequests.delete(`${index}:${begin}`);
|
||||||
|
// console.log(`[Worker] Received block ${index}:${begin} (${block.length} bytes) from ${this.host}`);
|
||||||
this.onPiece(index, begin, block);
|
this.onPiece(index, begin, block);
|
||||||
this.activeRequests--;
|
this.activeRequests--;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user