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

Do not parse the raw torrent file more than once in the code. #77

Open
jlouis opened this issue Jan 21, 2011 · 6 comments
Open

Do not parse the raw torrent file more than once in the code. #77

jlouis opened this issue Jan 21, 2011 · 6 comments
Labels

Comments

@jlouis
Copy link
Owner

jlouis commented Jan 21, 2011

We currently have many calls where we read the torrent file into its bcoded internal representation. This is mostly due to laziness. Only decode once, and then pass around the torrent file. One important part is to slowly change identification by FilePath of the torrent into identification by its InfoHash. This probably has to go first, before you can do the real work, namely parse-the-raw-file-only-once.

@edwardw
Copy link
Contributor

edwardw commented Jan 28, 2011

Looks like etorrent codes use two flavor of InfoHash. One is a binary():
crypto:sha(SomeThing).
All codes other than etorrent_dht submodule use this one.

The other is what etorrent_dht submodule uses, which is decoded from aforementioned binary() one:
integer_id(BinaryInfoHash:160) -> InfoHash.

I found such inconsistency confusing. Is there any particular reason to do that? If not, I will make them one.

@jlouis
Copy link
Owner Author

jlouis commented Jan 28, 2011

No, there is no reason from my point of view. It is worth checking with klaar though, since he is the author of the DHT subsystem. I'd really like to hinge torrent identification on the InfoHash in the future rather than the file location we are using now.

@edwardw
Copy link
Contributor

edwardw commented Jan 28, 2011

Yes, exactly. I was trying to do that and found this interesting distinction.

@edwardw
Copy link
Contributor

edwardw commented Jan 28, 2011

Pinged klaar.

@edwardw
Copy link
Contributor

edwardw commented Jan 31, 2011

Got answer from klaar. Quote: "The DHT subsystem uses an integer as the type for both info hashes and node ids because the DHT protocol defines the distance between nodes, and between nodes and info hashes as the integer value that you get when you 'xor' the two id's. "

After second thought, I'm not going to change the code (make them one) since it works now. Instead, I'll write klaar's answer into comment for future reference.

@jlouis
Copy link
Owner Author

jlouis commented Jan 31, 2011

+1 for that solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants