BitTorrent Module Weekly Update 2 - Node Types and Database Tables

Events happening in the community are now at Drupal community events on www.drupal.org.
bradfordcp's picture

What have I done this week?? A lot of awesome work! Earlier this week I was working on announce.php trying to figure out settings and keys that the tracker would need. That was fine until I talked to flk (shakur?) and we discussed my progress and what I was working on. He suggested that I stop work on the tracker and generate a data model for my module. Then work on how this model would interact with the module, and finally writing the core of the module. I took his advice and created the database structure first. After a few revisions and input from my mentor(chx) I had a solid data model. While developing this model I figured out how to store the torrents and the process to add a torrent, along with an added feature. We decided to modularize my module, first I will be creating a torrent node type. With this module a user may enter a title and description for their torrent and upload a .torrent file. The module then stores the entire torrent in the database (most torrents are under 100K) as well as plain text data that is pulled from the torrent such as announce url, files, info_hash. this way when constructing a view of the node the metadata does not need to be parsed, and when a user requests a torrent file for download the metadata can be retrieved without having to encode the plain text data that is in the database. After the node type is complete I will be working on the tracker portion. Since the announce url is stored in the database someone who wants to use this module has two options. They can enforce a rule stating that all uploaded torrents must be tracked by their drupal installation OR they may allow the user to choose whether to use the original tracker which is stored in the torrent file or to adjust the torrent file and use the tracker I am creating. I really like the direction this project is going.

As far as node type progression goes I am happy to report I have successfully created an info hash for a torrent file uploaded through my new content type. This is a big step as I am a little rusty with my php file handling skills. A big thanks goes to drewish for helping me with my hook_insert and hook_nodeapi questions. For anyone interested http://www.soc.deviantsolutions.net/test.php shows the two info hashes for my test torrent file. The top hash is the one that is being generated through php while the bottom is copied out of Azureus running the same torrent.

I have attached the database scheme. Feel free to comment with any thoughts and ideas.

AttachmentSize
tables.jpg40 KB

Comments

Thanks to my mentors too!!!

bradfordcp's picture

I thanked drewish in my post, but I forget to thank flk and chx. I am surprised they put up with my endless barrage of questions. Thanks for your help guys it is really appreciated.
~Chris

~Chris

nice work

shiveringweb's picture

yeay nice work mate :D.
Now that the ball has started rolling keep keep up the momentum.

one question in regards to the schema, how does the the tracker_users and active_users relate to each other?

The difference is...

bradfordcp's picture

tracker_users has persistent data for the users such as the total number of bytes uploaded and downloaded. This table has the potential to be expanded to include other data such as the number of torrents shared. It might end up getting dropped in favor of using the data field in the users table, but I am not sure. To continue with your question though, tracker_active_users contains all of the users who are currently downloading or uploading the torrent. If a connection is made to the tracker from a client there is a record in this table reflecting the client and their various statistics.
~Chris

~Chris

i understand, but how do you

shiveringweb's picture

i understand, but how do you connect each client that connected to a user... how can you tell which users are currently downloading and who they are ?

ie
lets say we know the user with uid is currently downloading...how can you show that in the _active_users table?

i am mumbling on or does that make sense?

PS yes i am flk ;)

By using sid from the

bradfordcp's picture

By using sid from the sessions table, we can link a uid to the current hostname. For example a user connects, we perform a lookup in the sessions table and retrieve their uid and store the sid in the bt_tracker_active_users table. What is nice is if the user's ip address changes their peer_id doesn't so we can still link the user to the connection.
~Chris

~Chris

SoC 2007

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: