Currently, for a peer to get a blob, it has to
- call blobs.want(id, cb) to cause the machinery to download a blob from a peer to the local file system (blob store)
- after the cb fired, call blobs.get(id) to get a stream of the blob data from the filesystem
The problem here is that the first byte of data will be available to the application only after the blob is transferred from another peer in its entirety. This becomes an issues when we are dealing with very large blobs (I have blobs of multiple GB) because the UI cannot show any feedback about sync progress of a particular blob.
I'd like to add an API that has the same net effect as the two steps above, but streams data to the application while it arrives from another peer and also informs its caller about the total blob size to expect ahead of time, so that a progress bar can be rendered.
Usage would be something like:
let meta
let total = 0
pull(
ssb.blobs.getLive(id),
pull.filter( data=>{
// first item is meta object
if (meta == undefined) {
meta = data
return false
}
return true
}),
pull.through( data =>{
total += data.length
console.log(`progress: ${total} of ${meta.size}`)
// can also calculate transfer speed etc
})
[ do something with the data, progressively ]
)
meta could be {size, peer}
I'll probably implement this with an instance of pull-notify per blob id that is live streamed
Any thoughts?
Currently, for a peer to get a blob, it has to
The problem here is that the first byte of data will be available to the application only after the blob is transferred from another peer in its entirety. This becomes an issues when we are dealing with very large blobs (I have blobs of multiple GB) because the UI cannot show any feedback about sync progress of a particular blob.
I'd like to add an API that has the same net effect as the two steps above, but streams data to the application while it arrives from another peer and also informs its caller about the total blob size to expect ahead of time, so that a progress bar can be rendered.
Usage would be something like:
meta could be
{size, peer}I'll probably implement this with an instance of pull-notify per blob id that is live streamed
Any thoughts?