-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stream for encoding #18
Comments
Not sure if I understand your question, but yes the library can encode bencoding. |
I think he's asking for the ability to do streaming decoding as the bits arrive on the wire. |
The text & sample are pretty clear about encoding not decoding... Not sure why you'd need a stream interface to encode a Javascript Object to beencoding...? Not sure to what extent this would even be possible. I have the feeling he wants to stream a datafile somewhere, and as it's being streamed, magically create the beencoded meta-data? Streaming decoding of deencoded dictonionaries works with the Stream object somebody implemented (I think you, even :). Or maybe I'm just being obtuse and am missing something entirely obvious... |
For example I want to create torrent file, from list of files. The list is big: 2000 files. To create torrent I must create infoDictionary. (using benc.encode) Both of this operations are heavy, so them can freeze application. So I want to be able to make this operations asynchronously. The real reason is that https://github.com/mafintosh/torrent-stream completely revalidates torrent infoDictionary before use the torrent. My application automatically search torrents which it uses. And I found torrent which is 2.5 MB, so application freezed for few minutes. |
I think I'm still not entirely clear what the problem is. Currently, the encode function takes the infoDictionary to be encoded. I can't really think a a scenario that the infoDict to encode is so huge that it would take more than a negligible amount of time. As I see it, the bottleneck is probably calculating the sha hash. You could try to pass the Buffer containing the encoded infodict to sha in pieces. I guess you separate the infoDict into pieces and call the various If you can post the dict you're trying to encode I can try to reproduce any performance issues you're having. Finally, from my point of view, it's unecessary to decode and reencode the dict to get the sha1 hash, you could just run the stream through the hash while you're receiving it. |
This can be closed. right? |
I guess. At least if you understood the original posters problem and it confuses you as it did me 14 years ago and you feel that this resolves it? May I ask why you're interested in a 14 year old issue? |
Currently we can stream file and decoding it.
Is is possible to implement encoding stream?
I want to do this
The text was updated successfully, but these errors were encountered: