You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: segregate command and query for announce request
This changes the API of the torrent repository. The method:
```
fn update_torrent_with_peer_and_get_stats(&self, info_hash: &InfoHash, peer: &peer::Peer) -> (bool, SwarmMetadata);
```
is replaced with:
```
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer);
fn get_swarm_metadata(&self, info_hash: &InfoHash) -> Option<SwarmMetadata>;
```
The performance is not affected. Benchmaring is still using both methods
in order to simulate `announce` requests.
1. The interface is simpler (command/query segregation.
2. In the long-term:
- Returning swarm metadata in the announce request could be
optional. The announce request process would be faster if the
tracker does not have to mantain the swarm data. This is not likely to
happen becuase the scrape request needs this metadata.
- New repository performance improvements could be implemented. This allow
decoupling peer lists from swarm metadata. The repository
internally can have two data strcutures one for the peer list and
another for the swarm metatada. Both using different locks.
0 commit comments