-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged Popularity, RemoteQuery and Version communities
- Loading branch information
Showing
36 changed files
with
1,312 additions
and
1,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
src/tribler/core/components/content_discovery/community/cache.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from asyncio import Future | ||
|
||
from ipv8.requestcache import RandomNumberCache | ||
from tribler.core.components.metadata_store.utils import RequestTimeoutException | ||
|
||
|
||
class SelectRequest(RandomNumberCache): | ||
def __init__(self, request_cache, prefix, request_kwargs, peer, processing_callback=None, timeout_callback=None): | ||
super().__init__(request_cache, prefix) | ||
self.request_kwargs = request_kwargs | ||
# The callback to call on results of processing of the response payload | ||
self.processing_callback = processing_callback | ||
# The maximum number of packets to receive from any given peer from a single request. | ||
# This limit is imposed as a safety precaution to prevent spam/flooding | ||
self.packets_limit = 10 | ||
|
||
self.peer = peer | ||
# Indicate if at least a single packet was returned by the queried peer. | ||
self.peer_responded = False | ||
|
||
self.timeout_callback = timeout_callback | ||
|
||
def on_timeout(self): | ||
if self.timeout_callback is not None: | ||
self.timeout_callback(self) | ||
|
||
|
||
class EvaSelectRequest(SelectRequest): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
# For EVA transfer it is meaningless to send more than one message | ||
self.packets_limit = 1 | ||
|
||
self.processing_results = Future() | ||
self.register_future(self.processing_results, on_timeout=RequestTimeoutException()) |
422 changes: 422 additions & 0 deletions
422
src/tribler/core/components/content_discovery/community/content_discovery_community.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/tribler/core/components/content_discovery/community/settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Sequence | ||
|
||
from ipv8.community import CommunitySettings | ||
from tribler.core.components.database.db.tribler_database import TriblerDatabase | ||
from tribler.core.components.metadata_store.db.store import MetadataStore | ||
from tribler.core.components.torrent_checker.torrent_checker.torrent_checker import TorrentChecker | ||
from tribler.core.utilities.notifier import Notifier | ||
|
||
|
||
class ContentDiscoverySettings(CommunitySettings): | ||
random_torrent_interval: float = 5 # seconds | ||
random_torrent_count: int = 10 | ||
max_query_peers: int = 20 | ||
maximum_payload_size: int = 1300 | ||
max_response_size: int = 100 # Max number of entries returned by SQL query | ||
|
||
binary_fields: Sequence[str] = ("infohash", "channel_pk") | ||
deprecated_parameters: Sequence[str] = ('subscribed', 'attribute_ranges', 'complete_channel') | ||
|
||
metadata_store: MetadataStore | ||
torrent_checker: TorrentChecker | ||
tribler_db: TriblerDatabase | None = None | ||
notifier: Notifier | None = None |
File renamed without changes.
Oops, something went wrong.