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

DHT Vote #79

Open
FLYBYME opened this issue Nov 24, 2015 · 7 comments
Open

DHT Vote #79

FLYBYME opened this issue Nov 24, 2015 · 7 comments

Comments

@FLYBYME
Copy link

FLYBYME commented Nov 24, 2015

Does anyone know how utorrent implements the "vote" system over the DHT?

I looked online but there is next to nothing about it.

Some information:
http://lists.ibiblio.org/pipermail/bittorrent/2011-January/002413.html

http://arxiv.org/ftp/arxiv/papers/1305/1305.0711.pdf

You get a message something like this:

{ a:
   { id: '907050177fb05376db71ce066663819503eb0a9a',
     target: '546d6d0e5aacfae66299f26a300a428c497b23b5',
     token: '5b3f3de3d4f5ba42721dac14b2076dc64bc829da',
     vote: 0 },
  q: 'vote',
  t: '+=\u0000\u0000',
  v: 'UT??',
  y: 'q' }

The only thing I dont get it the target They say its sha1(info-hash + "rating") but i dont know. So the rating 1-5 and 0 been the query for votes. So if a infohash has 5 votes ranging from 1 to 5 would you receive 5 responses?

Has anyone played around with this?

@pldubouilh
Copy link

It seems that the peers can cast their vote at sha1(info# + {1,2,3,4,5}). Although, it's not been bep'd so I think only utorrent would handle these requests.

And an user willing to check the ratings for a given infohash would DHT.get at sha1(info# + 1), sha1(info# + 2), sha1(info# + 3), sha1(info# + 4) and sha1(info# + 5). So 5 DHT.get, to receive the number of votes received for each rating.

That paper states that 1% of the total DHT traffic is related to votes (mostly 0 stars), and that seems to be like an awful lot. I'll try to hack something around bittorent-dht to see if I can reproduce that figure.

@mastilver
Copy link

@pldubouilh Thank you, that is really helpful 👍

@FLYBYME
Copy link
Author

FLYBYME commented Jan 26, 2016

So I played around with the idea.

Here is the code:

var DHT = require('bittorrent-dht');
var crypto = require('crypto');
function sha1(str) {
    return crypto.createHash('sha1').update(str).digest('hex')
}

var dht = new DHT();

dht.listen(8000, function() {
    console.log('now listening');
});

function lookup(infoHash) {
    console.log('lookup(' + infoHash + ')');

    function cb(err, result) {
        if (result)
            console.log(err, result);
    }

    for (var i = 0,
        j = 5; i < j; i++) {
        dht.get(sha1(infoHash + i), cb);
    };
}

dht.on('ready', function() {
    console.log('now ready');
});
dht.on('error', function(err) {
    console.log(err);
});
dht.on('warning', function(warning) {
    console.log(warning);
});
dht.on('vote', function(query, peer) {
    var infoHash = query.a.target.toString('hex');
    lookup(infoHash);
});

dht.on('announce', function(peer, infoHash) {
    lookup(infoHash.toString('hex'));
});

It is interesting that nodes send out a vote query. I dont think they use the get query but the vote. From what I understand the vote: 0 is the query for the votes from 1-5 so then vote: 1 would be a vote of one and so on.

Using the put method to keep track of how many votes would not work. The number of votes would keep getting overwritten.

@mastilver
Copy link

I think they are only using the vote even to broadcast the fact that their is new vote to query
So you are not querying the i+1 hash all the time

@pldubouilh
Copy link

Right, so I did some tests as well - the query is, indeed, vote and not get, so you'll have to change a few lines in client.js otherwise the message is considered as unexpected.

Also, for the record, it seems that the paper's correct. I receive a good amount of votes, and they are mostly 0...

@FLYBYME
Copy link
Author

FLYBYME commented Jan 27, 2016

@pldubouilh would you mind sharing your code?

@pldubouilh
Copy link

There you go. It's nothing really fancy, I just added a case: 'vote', so I can see what's happening instead of treating it as unexpected.

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

No branches or pull requests

3 participants