Re: PeerInfo and PeerId

Hi Peter,

I thought about PeerId being a VendorId like class (possibly a typedef for FixedSizeArray), so PeerId() will create a PeerId object internally storing a 20 bytes zero filled QByteArray.

“Peer id can be either a string that’s 20B long (that means that it was parsed correctly), or an empty string (original peer id was incorrect).”

We would not need stuff like that explicitly stated in the docs if we use a type that enforces certain invariants - PeerInfo is a FixedSizeArray <20> which is always 20B long and the default value is all null 20 bytes.

Yes, you’re right! I completely forgot that we’ll use a FixedSizeArray <20> class. Now it’s everything clear to me.

Yes, I think Uri could replace PeerInfo. If might be a good idea though define typedef Uri PeerInfo in module PeerInfo. I think it’s a good idea to use “concrete” types (PeerInfo) rather then generic ones (QByteArray) even if that would mean using a simple typedef. This approach would allow to easily change the mapping to a generic type or even implement a custom one. I’ve not used this approach very often, but that seems like a good idea to me! What do you think?

Ok - I was actually thinking about that one, too :). I agree that it will be better to use a typedef. I’ll make necessary changes and then I’ll let you know how it’s going and working.

Petr

Would you like to post a relpy?


This post is a reply to:
Re: PeerInfo and PeerId
Hi Petr, I’ll try to sumarize it, so we’ll see what needs (should) to be changed. I’ve checked the {Torrent, TrackerResponse}Parser classes and I think that there is currently no problem (more...)

Follow-ups:
Re: PeerInfo and PeerId
Hi Peter, I've pushed changes according to our discussion. I've replaced PeerInfo class with Uri class - see PeerInfo.h for more details. In the TrackerResponseParser I'm testing whether all 'peers' fields (more...)