willchapin / RubyTorrent

A simple BitTorrent client in Ruby
27 stars 4 forks source link

How to refactor Peer.rb to know when it is a Seed? #question #3

Open rafapolo opened 10 years ago

rafapolo commented 10 years ago

Hello, I've been using RubyTorrent in a huge project to distribute a Archive of Public Papers, but I have to refactor it in such way we could count all Peers that are real Seeds - which have 100% of the files, and thats where we ask for conceptual help. I think it can be inferred by the :state, or not? https://github.com/willchapin/RubyTorrent/blob/master/lib/ruby_torrent/peer.rb#L8 Thank you

willchapin commented 9 years ago

Hi, rafapolo. This is probably too late to be useful (sorry!), but if you want to identify a peer as being seed/non-seed, you will need to look at that peer's Bitfield. A peer with a full bitfield (ones for all pieces) is a seed peer.

Let me know if you have any additional questions!