Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Credit mining prototype #2064

Merged
merged 24 commits into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7226455
Channel boosting implementation
Oct 9, 2013
168f7cc
sessioncalling arg was removed a while ago.
Aug 18, 2015
bd87ab1
Updates for API changes
Aug 18, 2015
897cdff
Add missing __init__.py
Aug 18, 2015
d713895
Don't fail when a torrent not in the download list finishes.
Aug 18, 2015
9d3201b
Remove DOS newlines from BoostingManager modifications.
Aug 18, 2015
24ebb7b
WIP commit
Aug 24, 2015
2184356
WIP commit
Aug 28, 2015
b7010d8
Fix initial work in BoostingManager that cannot work
ardhipoetra Jun 27, 2016
a31b923
Revamped creditmining GUI
ardhipoetra Jun 27, 2016
9a87521
Extract peerlist to its own function
ardhipoetra Mar 18, 2016
6600773
Create function to translate peers into health
ardhipoetra Jun 27, 2016
d7d9ccf
Create holder in GUI if credit mining is not ready yet
ardhipoetra Jun 27, 2016
ae7576c
Start boosting manager if ready only
ardhipoetra Jun 27, 2016
9b9c01a
Add dirdialog for convenience choosing source
ardhipoetra Jun 27, 2016
c2e894b
Prevent GUI to do task when quitting
ardhipoetra May 9, 2016
a33b4c7
Clean onexit in BoostingManager
ardhipoetra Jun 27, 2016
6cc9d7d
Add and clean documentation in some functions needed
ardhipoetra May 3, 2016
2310579
Add credit mining preferences by SessionConfig
ardhipoetra May 27, 2016
a85ab3c
Refactor policies, constant, and function to different file
ardhipoetra May 31, 2016
66eb87f
Fix resume data to use configparser
ardhipoetra Jun 27, 2016
57e8636
Add logger.conf, Delete bootstraptribler.txt and boostchannel.py
ardhipoetra Jun 14, 2016
b11fd65
Fix switch policy when loading config
ardhipoetra Jun 8, 2016
b9d1940
Credit mining testcase
ardhipoetra Jun 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create function to translate peers into health
- implement "feedback" (random) policy if we can't determine the actual policy
- implement get_source_object to get source by flexible input (string/binary)
- put DownloadState recent value into sources and update variable related with it.
  • Loading branch information
ardhipoetra committed Jun 27, 2016
commit 66007737efec6faeb9fa87347894dd271c980ccb
3 changes: 2 additions & 1 deletion Tribler/Core/TorrentChecker/torrent_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ def _create_session_for_request(self, infohash, tracker_url):

# before creating a new session, check if the tracker is alive
if not self._session.lm.tracker_manager.should_check_tracker(tracker_url):
self._logger.warn(u"skipping recently failed tracker %s", tracker_url)
self._logger.warn(u"skipping recently failed tracker %s by %d times", tracker_url,
self._session.lm.tracker_manager.get_tracker_info(tracker_url)['failures'])
return

session = create_tracker_session(tracker_url, self._on_result_from_session)
Expand Down
53 changes: 53 additions & 0 deletions Tribler/Core/Utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,56 @@ def fix_torrent(file_path):
fixed_data = bencode(fixed_data)

return fixed_data

def translate_peers_into_health(peer_info_dicts, status=None):
# peer_info_dicts is a peer_info dictionary from LibTorrentDownloadImpl.create_peerlist_data
# status is libtorrent torrent status #TODO : unused for now
# purpose : where we want to measure a swarm's health but no tracker can be contacted

num_seeders = 0
num_leech = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assigned value of these variables are not used so these two lines could be removed.


num_all_peer = len(peer_info_dicts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to create a variables just to hold the length of this dict since num_all_peer is used only once.


upload_only = 0
finished = 0
unfinished_able_dl = 0
interest_in_us = 0

# collecting some statistics
for p_info in peer_info_dicts:
upload_only_b = False
finished_b = False
interest_in_us_b = False

if p_info['upload_only']:
upload_only+=1
upload_only_b = True
if p_info['uinterested']:
interest_in_us+=1
interest_in_us_b = True

if p_info['completed'] == 1:
finished+=1
finished_b = True
else:
unfinished_able_dl += 1 if upload_only_b else 0

'''
seeders potentials:
1. it's only want uploading right now (upload only)
2. it's finished (we don't know whether it want to upload or not)


leecher potentials:
1. it's interested in our piece
2. it's unfinished but it's not 'upload only' (it can't leech for some reason)
3. it's unfinished (less restrictive)

make sure to change those description when change the algorithm
'''

num_seeders = max(upload_only, finished)
num_leech = max(interest_in_us, min(unfinished_able_dl, num_all_peer - finished))
return (num_seeders, num_leech)

7 changes: 2 additions & 5 deletions Tribler/Policies/BoostingManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def set_share_mode_params(self, share_mode_target=None, share_mode_bandwidth=Non
def add_source(self, source):
if source not in self.boosting_sources:
args = (self.session, self.session.lm.threadpool, source, self.source_interval, self.max_torrents_per_source, self.on_torrent_insert)
# pylint: disable=star-args
# pylint: disable=star-args

try:
isdir = os.path.isdir(source)
Expand Down Expand Up @@ -455,9 +455,6 @@ def _logtorrentpeer(status, lt_torrent):

self.session.lm.threadpool.add_task(self.scrape_trackers, self.tracker_interval)

# save the old part
return None

def set_archive(self, source, enable):
if source in self.boosting_sources:
self.boosting_sources[source].archive = enable
Expand Down Expand Up @@ -600,7 +597,7 @@ def save_config(self):
elif isinstance(self.policy, SeederRatioPolicy):
policy = "seederratio"
config.set(__name__, "policy", policy)
with open(CONFIG_FILE, "w") as configf:
with open(CONFIG_FILE, "w ") as configf:
config.write(configf)

def log_statistics(self):
Expand Down
4 changes: 2 additions & 2 deletions boosting.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Tribler.Policies.BoostingManager]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these files, they are accidentally pushed I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's part of the 'identifier' of the configuration file

max_torrents_per_source = 100
max_torrents_per_source = 10
max_torrents_active = 20
source_interval = 300
swarm_interval = 300
Expand All @@ -9,5 +9,5 @@ logging_interval = 60
boosting_sources = ["http:https://bt.etree.org/rss/bt_etree_org.rdf"]
boosting_enabled = ["http:https://bt.etree.org/rss/bt_etree_org.rdf"]
boosting_disabled = []
policy = random
policy = seederratio