anacrolix / torrent

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

Count the number of bytes uploaded or downloaded. #872

Closed whr819987540 closed 5 months ago

whr819987540 commented 9 months 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 9 months ago

Are you looking for something like a seeding ratio?

whr819987540 commented 9 months 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 9 months 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 9 months 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 9 months 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 5 months ago

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