anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.58k stars 630 forks source link

Count the number of bytes uploaded or downloaded. #872

Closed whr819987540 closed 10 months ago

whr819987540 commented 1 year ago

I would like to build a mechanism that rewards or punishes users based on how many bytes they receive from or send to other peers so that more users would be willing to keep seeding for a while after downloading. As for bytes received, it could be found through torrent.ConnStats.BytesRead. But how about bytes sent? When I am downloading, I could send to other peers as well. When I finish downloading and start seeding, I could also send to other peers.

anacrolix commented 1 year ago

Are you looking for something like a seeding ratio?

whr819987540 commented 1 year ago

Seeding ratio could help because if I know this, the number of bytes that a peer send to others will also be known. But it would be better if torrent could directly supply the number.

anacrolix commented 1 year ago

Bytes sent and uploaded by the local client are recorded. I'm not sure about bytes sent by each peer, but that data is only easy to track while the peer remains connected to our local client. Which is it that you're after?

whr819987540 commented 1 year ago

As you said, I think 'Bytes sent and uploaded by the local client' is enough, which reflects how much the local client gets from others and does for others. For this purpose, which variable do you think is the most suitable? BytesRead and BytesWritten?

anacrolix commented 1 year ago

ConnStats.BytesWrittenData is data uploaded to peers, I think that's the one you want. Similarly any of the BytesRead fields for data received, depending on how specific you want to be.

anacrolix commented 10 months ago

I think this can be closed, the question was answered.