Compare commits

..

No commits in common. "uw-improve-miner-retry" and "master" have entirely different histories.

6 changed files with 14 additions and 70 deletions

View File

@ -1,6 +1,6 @@
{application,gmhive_client, {application,gmhive_client,
[{description,"Gajumaru Hive Client"}, [{description,"Gajumaru Hive Client"},
{vsn,"0.10.1"}, {vsn,"0.10.0"},
{registered,[]}, {registered,[]},
{applications,[kernel,stdlib,sasl,gproc,inets,ssl,enoise, {applications,[kernel,stdlib,sasl,gproc,inets,ssl,enoise,
gmconfig,gmhive_protocol,gmhive_worker]}, gmconfig,gmhive_protocol,gmhive_worker]},

View File

@ -3,10 +3,7 @@
{minimum_otp_vsn, "27.1"}. {minimum_otp_vsn, "27.1"}.
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{plugins, [ rebar3_hex {plugins, [rebar3_hex]}.
, {zx_rebar_plugin, {git, "https://git.qpq.swiss/QPQ-AG/zx_rebar_plugin",
{branch, "master"}}}
]}.
{post_hooks, [{compile, "make schema"}]}. {post_hooks, [{compile, "make schema"}]}.
@ -19,13 +16,12 @@
{gmconfig, {git, "https://git.qpq.swiss/QPQ-AG/gmconfig.git", {gmconfig, {git, "https://git.qpq.swiss/QPQ-AG/gmconfig.git",
{ref, "38620ff9e2"}}}, {ref, "38620ff9e2"}}},
{gproc, "1.0.0"}, {gproc, "1.0.0"},
{setup, {git, "https://github.com/uwiger/setup", {ref, "0430661"}}}, {setup, {git, "https://github.com/uwiger/setup", {ref, "d9b0b51"}}}
{zx, {zx, "https://gitlab.com/zxq9/zx.git", {ref, "2a0437f4"}, "0.14.0"}}
]}. ]}.
{relx, [ {relx, [
{release, { gmhive_client, "0.1.0" }, {release, { gmhive_client, "0.1.0" },
[sasl, enacl, enoise, gmhive_worker, {zx, load}, [sasl, enacl, enoise, gmhive_worker,
{gmhive_protocol, load}, gmserialization, gproc, gmconfig, gmhive_client ]}, {gmhive_protocol, load}, gmserialization, gproc, gmconfig, gmhive_client ]},
{dev_mode, true}, {dev_mode, true},
{sys_config, "./config/sys.config"}, {sys_config, "./config/sys.config"},
@ -40,5 +36,5 @@
{dialyzer, [ {warnings, [unknown]} {dialyzer, [ {warnings, [unknown]}
, {plt_apps, all_deps} , {plt_apps, all_deps}
, {base_plt_apps, [erts, kernel, stdlib, inets, zx]} , {base_plt_apps, [erts, kernel, stdlib, inets]}
]}. ]}.

View File

@ -38,12 +38,7 @@
{<<"gproc">>,{pkg,<<"gproc">>,<<"1.0.0">>},0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"1.0.0">>},0},
{<<"setup">>, {<<"setup">>,
{git,"https://github.com/uwiger/setup", {git,"https://github.com/uwiger/setup",
{ref,"0430661811269d007285f817467cbab7c4c31e96"}}, {ref,"d9b0b51505ff75c459f1ab62bd907ca5e3a32291"}},
0},
{<<"zx">>,
{zx,"https://gitlab.com/zxq9/zx.git",
{ref,"2a0437f416f94596e4e3b403603dbd028727742d"},
"0.14.0"},
0}]}. 0}]}.
[ [
{pkg_hash,[ {pkg_hash,[

View File

@ -46,7 +46,6 @@ stop(_State) ->
set_things_up() -> set_things_up() ->
maybe_add_logger_handler(), maybe_add_logger_handler(),
clean_up_log_directories(),
gmhc_counters:initialize(), gmhc_counters:initialize(),
gmhc_config:load_config(), gmhc_config:load_config(),
logger:set_module_level([gmhw_pow_cuckoo], notice), logger:set_module_level([gmhw_pow_cuckoo], notice),
@ -62,36 +61,6 @@ set_things_up() ->
end, end,
ok. ok.
clean_up_log_directories() ->
case setup_zomp:is_zomp_context() of
true ->
%% This is a temporary measure to remove old auto-created log sub-directories
LogDir = setup:log_dir(),
SubDirs = filelib:wildcard(LogDir ++ "/*/"),
[delete_if_empty(D) || D <- SubDirs];
false ->
ok
end.
delete_if_empty(Dir) ->
case filelib:wildcard(Dir ++ "/*") of
[] ->
Res = file:del_dir(Dir),
Res == ok;
Fs ->
case [filelib:is_regular(F) || F <- Fs] of
[] ->
case [F || F <- Fs, delete_if_empty(F) == false] of
[] ->
delete_if_empty(Dir);
[_|_] ->
false
end;
[_|_] ->
false
end
end.
maybe_add_logger_handler() -> maybe_add_logger_handler() ->
case is_headless() orelse application:get_env(gmhive_client, tty_logger, false) of case is_headless() orelse application:get_env(gmhive_client, tty_logger, false) of
true -> true ->

View File

@ -41,7 +41,6 @@
, candidate :: map() | 'undefined' , candidate :: map() | 'undefined'
, nonces = 1 :: pos_integer() , nonces = 1 :: pos_integer()
, workers = [] :: [worker()] , workers = [] :: [worker()]
, check_timer :: 'undefined' | reference()
}). }).
-define(CONNECTED(S), map_size(S#st.connected) > 0). -define(CONNECTED(S), map_size(S#st.connected) > 0).
@ -81,7 +80,6 @@ init([]) ->
N + Acc N + Acc
end, 0, IdleWorkers), end, 0, IdleWorkers),
process_flag(trap_exit, true), process_flag(trap_exit, true),
gproc_ps:subscribe(l, gmhw_miner_return),
{ok, #st{workers = IdleWorkers, nonces = TotalNonces}}. {ok, #st{workers = IdleWorkers, nonces = TotalNonces}}.
handle_call(total_nonces, _From, #st{nonces = Nonces} = S) -> handle_call(total_nonces, _From, #st{nonces = Nonces} = S) ->
@ -160,26 +158,18 @@ handle_info({'EXIT', Pid, Reason}, #st{ workers = Workers
gmhc_events:publish(error, ?ERR_EVT(#{error => worker_error, gmhc_events:publish(error, ?ERR_EVT(#{error => worker_error,
data => Reason})), data => Reason})),
Ws1 = incr_worker_error(W, Workers), Ws1 = incr_worker_error(W, Workers),
S1 = start_check_timer(S#st{workers = Ws1}), erlang:start_timer(100, self(), check_workers),
{noreply, S1}; {noreply, S#st{workers = Ws1}};
false -> false ->
%% ?LOG_DEBUG("EXIT apparently not from worker?? (~p)", [Pid]), %% ?LOG_DEBUG("EXIT apparently not from worker?? (~p)", [Pid]),
{noreply, S} {noreply, S}
end; end;
handle_info({timeout, _, check_workers}, #st{workers = Workers} = S) -> handle_info({timeout, _, check_workers}, #st{workers = Workers} = S) ->
S1 = maybe_request_nonces(S#st{check_timer = undefined}), S1 = maybe_request_nonces(S),
S2 = lists:foldl(fun(W, Sx) -> S2 = lists:foldl(fun(W, Sx) ->
maybe_restart_worker(W, Sx) maybe_restart_worker(W, Sx)
end, S1, Workers), end, S1, Workers),
{noreply, S2}; {noreply, S2};
handle_info({gproc_ps_event, gmhw_miner_return, Data}, S) ->
case Data of
#{info := #{result := {invalid_output, _}} = Info} ->
?LOG_NOTICE("Bad miner return: ~p", [Info]);
_ ->
ok
end,
{noreply, S};
handle_info(Msg, St) -> handle_info(Msg, St) ->
?LOG_DEBUG("Unknown msg: ~p", [Msg]), ?LOG_DEBUG("Unknown msg: ~p", [Msg]),
{noreply, St}. {noreply, St}.
@ -190,12 +180,6 @@ terminate(_Reason, _St) ->
code_change(_FromVsn, S, _Extra) -> code_change(_FromVsn, S, _Extra) ->
{ok, S}. {ok, S}.
start_check_timer(#st{check_timer = undefined} = S) ->
TRef = erlang:start_timer(100, self(), check_workers),
S#st{check_timer = TRef};
start_check_timer(S) ->
S.
report_solutions(Solutions, W, #st{} = S) when ?CONNECTED(S) -> report_solutions(Solutions, W, #st{} = S) when ?CONNECTED(S) ->
#{via := Via, seq := Seq} = W#worker.cand, #{via := Via, seq := Seq} = W#worker.cand,
Nonces = all_nonces(W), Nonces = all_nonces(W),
@ -284,7 +268,7 @@ handle_worker_result({worker_result, Result}, W, S) ->
gmhc_events:publish(error, ?ERR_EVT(#{error => worker_error, gmhc_events:publish(error, ?ERR_EVT(#{error => worker_error,
data => Result})), data => Result})),
Ws = incr_worker_error(W, S#st.workers), Ws = incr_worker_error(W, S#st.workers),
start_check_timer(S#st{workers = Ws}) S#st{workers = Ws}
end; end;
handle_worker_result(Error, W, S) -> handle_worker_result(Error, W, S) ->
?LOG_DEBUG("Got worker error from ~p: ~p", [W#worker.index, Error]), ?LOG_DEBUG("Got worker error from ~p: ~p", [W#worker.index, Error]),

View File

@ -2,16 +2,16 @@
{type,app}. {type,app}.
{modules,[]}. {modules,[]}.
{prefix,"gmhc"}. {prefix,"gmhc"}.
{desc,"Gajumaru Hive Client"}.
{author,"Ulf Wiger, QPQ AG"}. {author,"Ulf Wiger, QPQ AG"}.
{package_id,{"uwiger","gmhive_client",{0,10,1}}}. {desc,"Gajumaru Hive Client"}.
{deps,[{"uwiger","setup",{3,0,0}}, {package_id,{"uwiger","gmhive_client",{0,10,0}}}.
{"uwiger","gmhive_protocol",{0,3,1}}, {deps,[{"uwiger","gmhive_protocol",{0,3,1}},
{"uwiger","gmhive_worker",{0,5,1}}, {"uwiger","gmhive_worker",{0,5,1}},
{"uwiger","gmcuckoo",{1,2,4}}, {"uwiger","gmcuckoo",{1,2,4}},
{"otpr","eblake2",{1,0,1}}, {"otpr","eblake2",{1,0,1}},
{"otpr","base58",{0,1,1}}, {"otpr","base58",{0,1,1}},
{"otpr","gmserialization",{0,1,3}}, {"otpr","gmserialization",{0,1,3}},
{"uwiger","setup",{2,2,4}},
{"uwiger","gproc",{1,0,1}}, {"uwiger","gproc",{1,0,1}},
{"uwiger","gmconfig",{0,1,2}}, {"uwiger","gmconfig",{0,1,2}},
{"uwiger","enoise",{1,3,0}}]}. {"uwiger","enoise",{1,3,0}}]}.