Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d3d30425b | |||
| 92d061f572 |
+1
-1
@@ -3,6 +3,6 @@
|
||||
{registered,[]},
|
||||
{included_applications,[]},
|
||||
{applications,[stdlib,kernel]},
|
||||
{vsn,"0.3.6"},
|
||||
{vsn,"0.2.5"},
|
||||
{modules,[gajumine,gmc_con,gmc_conf,gmc_gui,gmc_sup]},
|
||||
{mod,{gajumine,[]}}]}.
|
||||
|
||||
+1
-2
@@ -3,7 +3,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(gajumine).
|
||||
-vsn("0.3.6").
|
||||
-vsn("0.2.5").
|
||||
-behavior(application).
|
||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||
-copyright("QPQ AG <craigeverett@qpq.swiss>").
|
||||
@@ -29,7 +29,6 @@ start(normal, _Args) ->
|
||||
{ok, _} = application:ensure_all_started(ssl),
|
||||
ok = application:ensure_started(hakuzaru),
|
||||
ok = application:ensure_started(zxwidgets),
|
||||
ok = application:ensure_started(gproc),
|
||||
gmc_sup:start_link().
|
||||
|
||||
|
||||
|
||||
+9
-40
@@ -3,7 +3,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(gmc_con).
|
||||
-vsn("0.3.6").
|
||||
-vsn("0.2.5").
|
||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||
-copyright("QPQ AG <craigeverett@qpq.swiss>").
|
||||
-license("GPL-3.0-or-later").
|
||||
@@ -101,28 +101,16 @@ start_link() ->
|
||||
|
||||
init(none) ->
|
||||
ok = log(info, "Starting"),
|
||||
{AProcs, AMem} = proc_mem(),
|
||||
TwoMaps = default_spec(mem) * 2,
|
||||
RProcs =
|
||||
case AProcs >= 2 of
|
||||
true -> 2;
|
||||
false -> 1
|
||||
end,
|
||||
RMem =
|
||||
case AMem >= TwoMaps of
|
||||
true -> TwoMaps;
|
||||
false -> default_spec(mem)
|
||||
end,
|
||||
{Acc, Keys, Network, MaxCores, MaxMem} =
|
||||
case read_conf() of
|
||||
{ok, C} ->
|
||||
{maps:get(account, C, none),
|
||||
maps:get(keys, C, []),
|
||||
maps:get(network, C, <<"mainnet">>),
|
||||
maps:get(max_cores, C, RProcs),
|
||||
maps:get(max_mem, C, RMem)};
|
||||
maps:get(max_cores, C, 2),
|
||||
maps:get(max_mem, C, 3550722201)};
|
||||
none ->
|
||||
{none, [], <<"mainnet">>, RProcs, RMem}
|
||||
{none, [], <<"mainnet">>, 2, 3550722201}
|
||||
end,
|
||||
State = #s{network = Network, acc = Acc, keys = Keys, max_cores = MaxCores, max_mem = MaxMem},
|
||||
{ok, start_gui(State)}.
|
||||
@@ -136,11 +124,6 @@ start_gui(State = #s{acc = none}) ->
|
||||
start_gui(State = #s{acc = AccID}) ->
|
||||
Window = gmc_gui:start_link(#{}),
|
||||
ok = gmc_gui:set_account(AccID),
|
||||
ok =
|
||||
case lists:member("autostart", zx_daemon:argv()) of
|
||||
false -> ok;
|
||||
true -> gmc_gui:start_stop()
|
||||
end,
|
||||
State#s{window = Window}.
|
||||
|
||||
|
||||
@@ -222,10 +205,7 @@ do_start_stop(#s{acc = PubKey, keys = Keys, network = Network, max_cores = MaxCo
|
||||
{Fatness, Type} =
|
||||
case os:type() of
|
||||
{unix, linux} ->
|
||||
case Network of
|
||||
<<"mainnet">> -> {"mean", "avx2"};
|
||||
<<"testnet">> -> {"mean", "generic"}
|
||||
end;
|
||||
{"mean", "generic"};
|
||||
{unix, darwin} ->
|
||||
% Check memory. >7gb gets mean, <7gb gets lean
|
||||
{"mean", "generic"};
|
||||
@@ -233,11 +213,7 @@ do_start_stop(#s{acc = PubKey, keys = Keys, network = Network, max_cores = MaxCo
|
||||
% Check memory. >7gb gets mean, <7gb gets lean
|
||||
% Check avx2.
|
||||
% Both should be provided by the F# start program
|
||||
case Network of
|
||||
% <<"mainnet">> -> {"mean", "avx2.exe"};
|
||||
<<"mainnet">> -> {"mean", "generic.exe"};
|
||||
<<"testnet">> -> {"mean", "generic.exe"}
|
||||
end
|
||||
{"mean", "generic"}
|
||||
end,
|
||||
Miner = filename:join(platform_dir(), unicode:characters_to_binary([Fatness, Bits, "-", Type])),
|
||||
Count = optimize_count(MaxCores, MaxMem),
|
||||
@@ -270,7 +246,7 @@ optimize_count(MaxC, MaxM) ->
|
||||
MaxMem = max(MapSize, MaxM),
|
||||
{Procs, Memory} = proc_mem(),
|
||||
MeanMaps = min(MaxMem, Memory) div MapSize,
|
||||
Recommended = min(MaxCores, min(Procs, MeanMaps)),
|
||||
Recommended = min(MaxCores, max(min(Procs, MeanMaps) - 1, 1)),
|
||||
Notice = fun(F, A) -> gmc_gui:message({notice, io_lib:format(F, A)}) end,
|
||||
ok = Notice("Physical Processors: ~p", [Procs]),
|
||||
ok = Notice("Physical Memory: ~p", [Memory]),
|
||||
@@ -288,15 +264,8 @@ platform_dir() ->
|
||||
{unix, linux} ->
|
||||
"linux_x86_64";
|
||||
{unix, darwin} ->
|
||||
case string:trim(os:cmd("uname -m")) of
|
||||
"arm64" ->
|
||||
"mac_arm64";
|
||||
"x86_64" ->
|
||||
"mac_x86_64";
|
||||
Other ->
|
||||
ok = log(info, "uname -m: ~p", [Other]),
|
||||
"mac_x86_64"
|
||||
end;
|
||||
% TODO: Check M2 vs x86
|
||||
"mac_m2";
|
||||
{win32, nt} ->
|
||||
"win_x86_64"
|
||||
end,
|
||||
|
||||
+19
-19
@@ -3,7 +3,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(gmc_conf).
|
||||
-vsn("0.3.6").
|
||||
-vsn("0.2.5").
|
||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||
-copyright("QPQ AG <craigeverett@qpq.swiss>").
|
||||
-license("GPL-3.0-or-later").
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
|
||||
-record(s,
|
||||
{wx = none :: none | wx:wx_object(),
|
||||
frame = none :: none | wx:wx_object(),
|
||||
lang = en :: en | jp,
|
||||
j = none :: none | fun(),
|
||||
net = none :: none | wx:wx_object(),
|
||||
acc = none :: none | wx:wx_object(),
|
||||
keys = none :: none | wx:wx_object(),
|
||||
cores = 2 :: pos_integer(),
|
||||
memory = 3550722201 :: pos_integer()}).
|
||||
{wx = none :: none | wx:wx_object(),
|
||||
frame = none :: none | wx:wx_object(),
|
||||
lang = en :: en | jp,
|
||||
j = none :: none | fun(),
|
||||
net = none :: none | wx:wx_object(),
|
||||
acc = none :: none | wx:wx_object(),
|
||||
keys = none :: none | wx:wx_object(),
|
||||
cores = none :: none | wx:wx_object(),
|
||||
memory = none :: none | wx:wx_object()}).
|
||||
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ init({Prefs, {Net, Acc, Keys, {AProcs, AMem, MProcs, MMem}}}) ->
|
||||
ok = wxFrame:center(Frame),
|
||||
true = wxFrame:show(Frame),
|
||||
State =
|
||||
#s{wx = WX, frame = Frame,
|
||||
lang = Lang, j = J,
|
||||
net = Network, acc = AccTx, keys = KeysTx,
|
||||
#s{wx = WX, frame = Frame,
|
||||
lang = Lang, j = J,
|
||||
net = Network, acc = AccTx, keys = KeysTx,
|
||||
cores = CoresTx, memory = MemoryTx},
|
||||
{Frame, State}.
|
||||
|
||||
@@ -205,7 +205,7 @@ done(State = #s{net = Network, acc = AccTx, keys = KeysTx, cores = CoresTx, memo
|
||||
1 -> <<"testnet">>;
|
||||
_ -> <<"mainnet">>
|
||||
end,
|
||||
AccID = string:trim(wxTextCtrl:getValue(AccTx)),
|
||||
AccID = wxTextCtrl:getValue(AccTx),
|
||||
MOAR_IDs = wxTextCtrl:getValue(KeysTx),
|
||||
CoreS = wxTextCtrl:getValue(CoresTx),
|
||||
GigsS = wxTextCtrl:getValue(MemTx),
|
||||
@@ -213,16 +213,16 @@ done(State = #s{net = Network, acc = AccTx, keys = KeysTx, cores = CoresTx, memo
|
||||
buh_bye(State).
|
||||
|
||||
cores("") ->
|
||||
2;
|
||||
none;
|
||||
cores(CoreS) ->
|
||||
try
|
||||
list_to_integer(CoreS)
|
||||
catch
|
||||
_:_ -> 2
|
||||
_:_ -> none
|
||||
end.
|
||||
|
||||
bytes("") ->
|
||||
3550722201;
|
||||
none;
|
||||
bytes(GigsS) ->
|
||||
try
|
||||
list_to_integer(GigsS) * gig()
|
||||
@@ -231,14 +231,14 @@ bytes(GigsS) ->
|
||||
try
|
||||
trunc(list_to_float(GigsS) * gig())
|
||||
catch
|
||||
_:_ -> 3550722201
|
||||
_:_ -> none
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
% NOTE: 32 is space, 12288 is full-width space.
|
||||
binify_keys(MOAR) ->
|
||||
lists:usort([list_to_binary(K) || K <- string:lexemes(MOAR, [$\r, $\n, 32, 12288, $\t, $,, $;])]).
|
||||
[list_to_binary(K) || K <- string:lexemes(MOAR, [$\r, $\n, 32, 12288, $\t, $,, $;])].
|
||||
|
||||
|
||||
acc(none) -> "";
|
||||
|
||||
+3
-32
@@ -3,14 +3,14 @@
|
||||
%%% @end
|
||||
|
||||
-module(gmc_gui).
|
||||
-vsn("0.3.6").
|
||||
-vsn("0.2.5").
|
||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||
-copyright("QPQ AG <craigeverett@qpq.swiss>").
|
||||
-license("GPL-3.0-or-later").
|
||||
|
||||
-behavior(wx_object).
|
||||
-include_lib("wx/include/wx.hrl").
|
||||
-export([ask_conf/0, set_account/1, difficulty/1, speed/1, candidate/1, message/1, start_stop/0]).
|
||||
-export([ask_conf/0, set_account/1, difficulty/1, speed/1, candidate/1, message/1]).
|
||||
-export([start_link/1]).
|
||||
-export([init/1, terminate/2, code_change/3,
|
||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
||||
@@ -79,10 +79,6 @@ message(Terms) ->
|
||||
wx_object:cast(?MODULE, {message, Terms}).
|
||||
|
||||
|
||||
start_stop() ->
|
||||
wx_object:cast(?MODULE, start_stop).
|
||||
|
||||
|
||||
|
||||
%%% Startup Functions
|
||||
|
||||
@@ -191,9 +187,6 @@ handle_cast({candidate, Block}, State) ->
|
||||
handle_cast({message, Terms}, State) ->
|
||||
NewState = do_message(Terms, State),
|
||||
{noreply, NewState};
|
||||
handle_cast(start_stop, State) ->
|
||||
NewState = start_stop(State),
|
||||
{noreply, NewState};
|
||||
handle_cast(Unexpected, State) ->
|
||||
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
||||
{noreply, State}.
|
||||
@@ -284,7 +277,7 @@ do_message({pool_notification, #{info := #{msg := MSG}}}, State = #s{height = He
|
||||
ok = wxStaticText:setLabel(CandT, Candidate),
|
||||
State;
|
||||
#{solution_accepted := #{seq := Seq}} ->
|
||||
Entry = io_lib:format("~nThe hive has produced a solution! Sequence: ~w", [Seq]),
|
||||
Entry = io_lib:format("~nSolution Accepted! You solved one! Sequence: ~w", [Seq]),
|
||||
do_message2(Entry, State);
|
||||
Other ->
|
||||
Entry = io_lib:format("~nUnexpected 'pool_notification': ~tp", [Other]),
|
||||
@@ -296,28 +289,6 @@ do_message({connected, _}, State) ->
|
||||
do_message({disconnected, _}, State) ->
|
||||
Entry = "\nDisconnected!",
|
||||
do_message2(Entry, State);
|
||||
do_message({error, #{info := #{info := #{error := get_failed, data := {error, #{code := 404}}, url := URL}}}}, State) ->
|
||||
ID =
|
||||
case uri_string:parse(URL) of
|
||||
#{path := Path} ->
|
||||
lists:last(string:split(Path, "/", trailing));
|
||||
{error, Reason, Info} ->
|
||||
ok = log(warning, "uri_string:parse/1 failed with: ~p: ~p", [Reason, Info]),
|
||||
"UNKNOWN"
|
||||
end,
|
||||
Format =
|
||||
"\nLookup for mining ID ~s failed."
|
||||
"\nCheck that you have joined the hive and have your account ID configured correctly.",
|
||||
Entry = io_lib:format(Format, [ID]),
|
||||
do_message2(Entry, State);
|
||||
do_message({error, #{info := #{info := #{error := get_failed, data := {error, #{code := 443}}}}}}, State) ->
|
||||
Entry =
|
||||
"\nThis system is not providing the needed TLS CA Certificate."
|
||||
"\nlease contact the support community and let them know you have a 443 error with GajuMine.",
|
||||
do_message2(Entry, State);
|
||||
do_message({error, #{info := #{info := #{error := connect_failure, data := {error, failed}}, module := gmhc_eureka}}}, State) ->
|
||||
Entry = "\nConnection terminated. Retrying.",
|
||||
do_message2(Entry, State);
|
||||
do_message(Terms, State) ->
|
||||
tell(info, "~p", [Terms]),
|
||||
Entry = io_lib:format("~n~tp", [Terms]),
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(gmc_sup).
|
||||
-vsn("0.3.6").
|
||||
-vsn("0.2.5").
|
||||
-behaviour(supervisor).
|
||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||
-copyright("QPQ AG <craigeverett@qpq.swiss>").
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
{type,gui}.
|
||||
{modules,[]}.
|
||||
{prefix,"gmc"}.
|
||||
{desc,"Mining client for the Gajumaru Root"}.
|
||||
{author,"Craig Everett"}.
|
||||
{package_id,{"qpq","gajumine",{0,3,6}}}.
|
||||
{deps,[{"uwiger","gmhive_client",{0,9,3}},
|
||||
{"uwiger","gmhive_protocol",{0,2,0}},
|
||||
{"uwiger","gmcuckoo",{1,2,4}},
|
||||
{"uwiger","gmhive_worker",{0,5,1}},
|
||||
{"qpq","cuckoo_cpu",{0,3,2}},
|
||||
{desc,"Mining client for the Gajumaru Root"}.
|
||||
{package_id,{"qpq","gajumine",{0,2,5}}}.
|
||||
{deps,[{"uwiger","gmhive_client",{0,4,4}},
|
||||
{"uwiger","gmcuckoo",{1,2,3}},
|
||||
{"qpq","cuckoo_cpu",{0,3,0}},
|
||||
{"uwiger","gmhive_worker",{0,3,0}},
|
||||
{"uwiger","gmconfig",{0,1,2}},
|
||||
{"uwiger","gproc",{1,0,1}},
|
||||
{"uwiger","gmhive_protocol",{0,1,1}},
|
||||
{"uwiger","enoise",{1,3,0}},
|
||||
{"uwiger","setup",{2,2,4}},
|
||||
{"otpr","hakuzaru",{0,6,1}},
|
||||
|
||||
Reference in New Issue
Block a user