Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeding re-stores chunks even if they are already stored #524

Closed
DiegoRBaquero opened this issue Dec 11, 2015 · 1 comment · Fixed by #1398
Closed

Seeding re-stores chunks even if they are already stored #524

DiegoRBaquero opened this issue Dec 11, 2015 · 1 comment · Fixed by #1398

Comments

@DiegoRBaquero
Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Dec 11, 2015

When you seed a file, it doesn't matter if the pieces are already on the store, it will create a ChunkStoreWriteStream and re-store them.

The verifying happens in Torrent._onMetadata, called on Torrent._onSwarnListening
The re-storing happens in Torrent.load, called in WebTorrent.seed

webtorrent:torrent got metadata +5ms
webtorrent:torrent verifying existing torrent data +3ms
webtorrent:torrent piece verified 0 +34ms
webtorrent:torrent piece verified 1 +1ms
webtorrent:torrent piece verified 2 +1ms
webtorrent:torrent done verifying +2ms
webtorrent:torrent on store +1ms
webtorrent:torrent select 0-2 (priority 0) +1ms
webtorrent:torrent file done: PMC-InformelaMuestra.pdf +3ms
webtorrent:torrent torrent done: 307f97a2e9264a5c17d04dd83aae6069d249a287 +1ms
bittorrent-tracker send `complete` +0ms
function onData(chunk) {
    if (self.destroyed) return
    store.put(index, chunk)
    index += 1
  }
put 0 from function (index, buf, cb) {
  console.info(arguments.callee.caller.toString())
  var self = this
  self.mem[index] = buf
  self.store.put(index, buf, function (err) {
    self.mem[index] = null
    if (cb) cb(err)
  })
}
function onData(chunk) {
    if (self.destroyed) return
    store.put(index, chunk)
    index += 1
  }
put 1 from function (index, buf, cb) {
  console.info(arguments.callee.caller.toString())
  var self = this
  self.mem[index] = buf
  self.store.put(index, buf, function (err) {
    self.mem[index] = null
    if (cb) cb(err)
  })
}
function onData(chunk) {
    if (self.destroyed) return
    store.put(index, chunk)
    index += 1
  }
put 2 from function (index, buf, cb) {
  console.info(arguments.callee.caller.toString())
  var self = this
  self.mem[index] = buf
  self.store.put(index, buf, function (err) {
    self.mem[index] = null
    if (cb) cb(err)
  })
}
webtorrent:torrent torrent done: 307f97a2e9264a5c17d04dd83aae6069d249a287 +54ms
bittorrent-tracker send `complete` +1ms
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Feb 11, 2016

You're right. We can make two improvements here:

  1. Eliminate the verification step for ALL input types to client.seed, since it'll obviously be correct.
  2. Eliminate the call to torrent.load (streaming into the store) when input is a filesystem path.
@feross feross added accepted and removed accepted labels May 3, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.