Skip to content

Commit

Permalink
add support creating plots for pools
Browse files Browse the repository at this point in the history
  • Loading branch information
FairWindCo committed Jul 22, 2021
1 parent 48bc63a commit c84d170
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions chia_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def convert_param_to_attribute(key, value):
return f'-p {value}'
if key == 'farmer_pub_key' and value:
return f'-f {value}'
if key == 'pool_contract_address' and value:
return f'-с {value}'
return ''


Expand Down
11 changes: 9 additions & 2 deletions chia_thread_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_hash(password):
'auto_find_exe',
'pause_before_start',
'recheck_work_dir',
'fingerprint', 'pool_pub_key', 'farmer_pub_key',
'fingerprint', 'pool_pub_key', 'farmer_pub_key', 'pool_contract_address',
'start_node', 'set_peer_address',
'start_shell', 'shell_name', 'p_open_shell', 'code_page',
'bitfield_disable']
Expand All @@ -46,7 +46,7 @@ def get_threads_configs():
'auto_find_exe': True,
'pause_before_start': 0,
'recheck_work_dir': False,
'fingerprint': None, 'pool_pub_key': None, 'farmer_pub_key': None,
'fingerprint': None, 'pool_pub_key': None, 'farmer_pub_key': None, 'pool_contract_address': None,
'start_node': None, 'set_peer_address': None,
'start_shell': False, 'shell_name': 'powershell', 'p_open_shell': False, 'code_page': 'cp1251',
'bitfield_disable': 'False', 'web_server_port': 5050, 'web_server_debug': False,
Expand Down Expand Up @@ -86,6 +86,13 @@ def get_threads_configs():
class ChieThreadConfig:
def __init__(self, config):
self.config = config
# pool_contract_address TEXT
# Address of where the pool reward will be
# sent to. Only used if alt_fingerprint and
# pool public key are None
if config['pool_contract_address'] is not None:
config['fingerprint'] = None
config['pool_pub_key'] = None
self.name = config['name']
self.num_plots = int(config.get('plots_count', 1))
self.num_parallel = int(config.get('parallel_plot', 1))
Expand Down
5 changes: 5 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ def render_config(request, thread_info=None):
thread_info.config['code_page'])
thread_info.config['shell_name'] = request.form.get('shell_name',
thread_info.config['shell_name'])
thread_info.config['pool_contract_address'] = request.form.get('pool_contract_address',
thread_info.config['pool_contract_address'])
if thread_info.config['pool_contract_address'] is not None:
thread_info.config['fingerprint'] = None
thread_info.config['pool_pub_key'] = None

if new_thread:
app.ctx.processor.add_new_thread(thread_info.config)
Expand Down
6 changes: 4 additions & 2 deletions main_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from PerfThread import PerfThread
from TelegramSenderThread import TelegramSenderThread
from TelegramThread import TelegramThread
from chia_thread_config import get_threads_configs, ChieThreadConfig
from chia_thread_config import ChieThreadConfig
from utility.SeparateSubprocessThread import get_command_for_execute_with_shell
from utility.utils import check_bool, GIGABYTE, get_disks_info_str
from utility.utils import check_bool, GIGABYTE, get_disks_info_str, get_from_dicts


class MainThread(Thread):
Expand Down Expand Up @@ -129,6 +129,8 @@ def get_main_info(self):
'threads': self.threads,
'current_time': now,
'plots': self.info.wallet_info.get('count_plots', 'UNKNOWN'),
'farm_sync': get_from_dicts(self.info.wallet_info, 'blockchain.blockchain_state.sync.synced'),
'wallet_sync': get_from_dicts(self.info.wallet_info, 'wallet_sync.synced'),
'sync': self.info.global_sync,
}

Expand Down
2 changes: 1 addition & 1 deletion templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row flex-wrap mt-5">
<div class="col-12 card">
<div class="card-title text-center row">
<h5 class="text-center col-8">Состояние системы {{current_time}} Синхр:{{sync}} Плоты:{{plots}} </h5>
<h5 class="text-center col-8">Состояние системы {{current_time}} Синхр:{{sync}} Плоты:{{plots}} Ферма:{{farm_sync}} Кошелек:{{wallet_sync}}</h5>
<a class="col-4 btn button btn-dark" href="/">Обновить</a>
</div>
<div class="row text-center flex-wrap">
Expand Down
3 changes: 3 additions & 0 deletions templates/modify.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ <h5 class="text-center">Выполнено {{current_task}} из {{count_task}}<
<span class="col-3">Деление процесса</span>
<input type="number" class="col-3 username" id="parallel_plot" name="parallel_plot"
placeholder="Разделить процесс" value="{{parallel_plot}}">
<span class="col-3">Pool contract Address</span>
<input type="text" class="col-8 m-1 username" id="pool_contract_address" name="pool_contract_address"
placeholder="fingerprint" value="{{pool_contract_address|default('', true)}}">
<span class="col-3">Fingerprint</span>
<input type="text" class="col-8 m-1 username" id="fingerprint" name="fingerprint"
placeholder="fingerprint" value="{{fingerprint|default('', true)}}">
Expand Down
15 changes: 15 additions & 0 deletions utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,18 @@ def is_writable(directory):
import errno
if x.errno == errno.EACCES:
return False


def get_from_dicts(dict_: dict, name: str):
if name and dict_:
pos = name.find('.')
if pos > 0:
current_element = dict_.get(name[:pos], None)
if current_element and isinstance(current_element, dict):
return get_from_dicts(current_element, name[pos+1:])
else:
return current_element
else:
return dict_.get(name, None)
else:
return None

0 comments on commit c84d170

Please sign in to comment.