Refactor peer management#13
Conversation
bedeho
left a comment
There was a problem hiding this comment.
A)
My head might be spinning after a really really long day, but I dont think I can review this with any confidence. You will have to walk me through this.
B)
I feel like I dont understand how the two maps relate to one another, hence the request for more clarity on their characterisations. However, I suspect we are not capturing as much as we can at compile time right now by having two maps. If we add some more structure form our types I think we can get some more safety and clarity for free, but lets see.
| // your own peer_plugin. If you want to keep references to it, use weak_ptr. | ||
| // NB: All peers are added, while not all are added to _session, see below. | ||
| std::map<libtorrent::tcp::endpoint, boost::weak_ptr<PeerPlugin> > _peers; | ||
| std::map<PeerPlugin*, boost::weak_ptr<PeerPlugin> > _peerPlugins; |
There was a problem hiding this comment.
Given that we have two maps, I think characterisations of the map members has to be exact.
An exact constraint gives the precise conditions for membership, i.e. an invariant, which by implication tells you exactly when things are added, and when they are removed.
| // Maps endpoint to corresponding peer_plugin. Peers get added to this map after the initial | ||
| // bittorrent handshake and if they pass the connection screening, and only if no existing established | ||
| // connection exists with the same endpoint. | ||
| std::map<libtorrent::tcp::endpoint, boost::weak_ptr<PeerPlugin> > _activePeerPlugins; |
| Coin::PubKeyHash _finalPkHash; | ||
| }; | ||
|
|
||
| struct TorrentPluginAdded : public libtorrent::torrent_alert { |
There was a problem hiding this comment.
It looks to me as if the TorrentPluginAdded/removed events are also gone now? If so, that is really really nice.
|
|
||
| struct TorrentPluginAdded : public libtorrent::torrent_alert { | ||
|
|
||
| TorrentPluginAdded(libtorrent::aux::stack_allocator& alloc, |
| status::TorrentPlugin status; | ||
| }; | ||
|
|
||
| struct TorrentPluginRemoved : public libtorrent::torrent_alert { |
Uh oh!
There was an error while loading. Please reload this page.