-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathplots.py
More file actions
91 lines (71 loc) · 2.71 KB
/
plots.py
File metadata and controls
91 lines (71 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import logging
def create(*args, chia_location='chia', backend='chia', **kwargs):
backend_command = _get_backend_command(backend, chia_location)
backend_flags = _get_backend_flags(backend, *args, **kwargs)
for key, value in backend_flags.items():
flag = f'-{key}'
backend_command.append(flag)
if value == '':
continue
backend_command.append(str(value))
return backend_command
def _get_backend_command(backend, chia_location):
logging.debug(f'Parsing backend commands for {backend}')
backend_commands = dict(
chia=[chia_location, 'plots', 'create'],
madmax=[chia_location],
)
return backend_commands.get(backend)
def _get_backend_flags(backend, *args, **kwargs):
logging.debug(f'Parsing backend flags for {backend}')
backend_parsers = dict(
chia=_get_chia_flags,
madmax=_get_madmax_flags,
)
backend_parser = backend_parsers.get(backend)
return backend_parser(*args, **kwargs)
def _get_chia_flags(size, memory_buffer, temporary_directory, destination_directory, threads, buckets, bitfield,
temporary2_directory=None, farmer_public_key=None, pool_public_key=None,
exclude_final_directory=False, pool_contract_address=None, **kwargs):
flags = dict(
k=size,
b=memory_buffer,
t=temporary_directory,
d=destination_directory,
r=threads,
u=buckets,
)
if temporary2_directory is not None:
flags['2'] = temporary2_directory
if farmer_public_key is not None:
flags['f'] = farmer_public_key
if pool_public_key is not None:
flags['p'] = pool_public_key
if bitfield is False:
flags['e'] = ''
if exclude_final_directory:
flags['x'] = ''
if pool_contract_address is not None:
flags['c'] = pool_contract_address
return flags
def _get_madmax_flags(temporary_directory, destination_directory, threads, buckets,
buckets_p3=None, threadX_p2=None, temporary2_directory=None, farmer_public_key=None, pool_public_key=None, pool_contract_address=None, **kwargs):
flags = dict(
r=threads,
t=temporary_directory,
d=destination_directory,
u=buckets,
)
if temporary2_directory is not None:
flags['2'] = temporary2_directory
if farmer_public_key is not None:
flags['f'] = farmer_public_key
if pool_public_key is not None:
flags['p'] = pool_public_key
if pool_contract_address is not None:
flags['c'] = pool_contract_address
if buckets_p3 is not None:
flags['v'] = buckets_p3
if threadX_p2 is not None:
flags['K'] = threadX_p2
return flags