Hi Petr,
I was reviewing your calitko-dev,163 revision. Here are some comments and ideas. :-)
testLoadFieldPeersOnePeerInfoPortZero(), testLoadFieldPeersOnePeerInfoPortTooBig() passing a 0 port is semantically incorrect. My question in general is whether we should do a full validation of the data in the reader (both correct format and correct value ranges) or should we only check for correct format and assign Null values to field with invalid ranges. Using Nulls would allow us to use the information that is correct (e.g. a single bad peer port would not render all the 20 returned peers invalid). What do you think?
PeerInfo – that might be the first class which we could substitute with Uri. The actual contents and format of the URI does not need to be known by class that stores it and passes it around (e.g. BitTorrent’s Transfter). TorrentResponseParser would convert the data from the bencoded dictionary into an Uri object, which TransferSession would split into its components to connect to the host and do the handshaking. We could use the scheme bt-peer (which does not to be formally registered as we only use it internally):
Using an hierarchical URI:
bt-peer://ipv6orv4:port?id=agd538×9fo4bf85jg076
Using a non-hierarchical URI:
bt-peer:ipv6orv4:port:agd538×9fo4bf85jg076
The advantage of using the hierarchical variant is that we can easily extract the individual fields using existing Uri functions and then convert them to the corresponding types (QhostAddress, uint16, PeerId). When such a URI is passed to a TransferSession (or TransferSessionFactory), it will first assert that the scheme is bt-peer, then will know how to make a tcp URI (from the authority component of the bt-peer URI) which will be passed to a TransportFactory object that will create the corresponding SocketTransport. I’m not clear about how to pass additional transport parameters to TransportFactory in a generic way (e.g. read and write buffer sizes). Maybe append a query item to the tcp URI? We should experiment…
PeerId could be a class like VendorCode – it stores the raw ID and would provide helpers to extract the Client name and version. What do you think?
Regards,
Peter
