Compare commits

...

11 Commits

Author SHA1 Message Date
491b9f3010 Merge pull request 'uw-miner-config' (#4) from uw-miner-config into master
Reviewed-on: #4
2025-05-28 01:56:37 +09:00
Ulf Wiger
006cb0140c Update gmcuckoo dep in zomp 2025-05-27 14:11:31 +02:00
Ulf Wiger
5604bef707 update dep (gmhive_worker), bump zomp version (0.4.0) 2025-05-24 12:04:56 +02:00
Ulf Wiger
c1bb026cb4 remove executable_group from config 2025-05-24 10:30:35 +02:00
Ulf Wiger
680631ed34 update zx vsn to 0.3.2 2025-05-23 15:39:59 +02:00
Ulf Wiger
0e16b59647 Continue after reported solution 2025-05-23 15:30:28 +02:00
Ulf Wiger
4961fdfff4 More robust worker stop/restart 2025-05-23 07:01:37 +02:00
Ulf Wiger
9038158c12 fix deps, zomp meta (v 0.2.1) 2025-05-22 12:31:52 +02:00
Ulf Wiger
d45f64f027 Change executable_groups and add bin_dir hook 2025-05-21 22:40:40 +02:00
Ulf Wiger
476bedfdac Also allow setting of 'network' via gmhc_app:start/1 2025-05-21 12:10:25 +02:00
Ulf Wiger
29fbfb3c87 Fix zomp's app file, config from cmd line, add network config 2025-05-20 23:40:54 +02:00
10 changed files with 115 additions and 184 deletions

View File

@ -1,102 +1,16 @@
{application,gmhive_client, {application,gmhive_client,
[{description,"Gajumaru Hive client"}, [{description,"Gajumaru Hive Client"},
{vsn,"0.2.1"}, {vsn,"0.4.1"},
{registered,[]}, {registered,[]},
{applications,[kernel,stdlib,sasl,gproc,enoise,gmconfig, {applications,[kernel,stdlib,sasl,gproc,inets,ssl,enoise,
gmhive_protocol,gmhive_worker]}, gmconfig,gmhive_protocol,gmhive_worker]},
{mod,{gmhive_client,[]}}, {mod,{gmhc_app,[]}},
{start_phases,[{connect_to_primary,[]}]}, {start_phases,[{connect_to_primary,[]}]},
{env,[]}, {env,[]},
{modules,[base58,eblake2,eblake2_tests,timing,enacl_eqc, {modules,[gmhc_app,gmhc_config,gmhc_config_schema,
enacl_ext_eqc,enacl,enacl_ext,enacl_nif,enacl_SUITE,
enoise,enoise_cipher_state,enoise_connection,
enoise_crypto,enoise_hs_state,enoise_keypair,
enoise_protocol,enoise_sym_state,
enoise_bad_data_tests,enoise_chiper_state_tests,
enoise_crypto_tests,enoise_hs_state_tests,
enoise_protocol_tests,enoise_sym_state_tests,
enoise_tests,enoise_utils,test_utils,gmconfig,
gmconfig_schema_helpers,gmconfig_schema_utils,
gmcuckoo,gmhc_app,gmhc_config,gmhc_config_schema,
gmhc_connector,gmhc_connectors_sup,gmhc_counters, gmhc_connector,gmhc_connectors_sup,gmhc_counters,
gmhc_eureka,gmhc_events,gmhc_handler,gmhc_server, gmhc_eureka,gmhc_events,gmhc_handler,gmhc_server,
gmhc_sup,gmhc_workers,gmhive_client,gmhp_msgs, gmhc_sup,gmhc_workers,gmhive_client]},
gmhw_blake2b_256,gmhw_pow,gmhw_pow_cuckoo,
gmhw_siphash24,gmcuckoo_SUITE,gmhw_pow_cuckoo_tests,
gmhw_pow_tests,gmser_api_encoder,gmser_chain_objects,
gmser_contract_code,gmser_delegation,gmser_dyn,
gmser_id,gmser_rlp,gmserialization,
gmser_api_encoder_tests,gmser_chain_objects_tests,
gmser_contract_code_tests,gmser_delegation_tests,
gmser_rlp_tests,gproc,gproc_app,gproc_bcast,
gproc_dist,gproc_info,gproc_init,gproc_lib,
gproc_monitor,gproc_pool,gproc_ps,gproc_pt,gproc_sup,
setup,setup_app,setup_file,setup_file_io_server,
setup_gen,setup_lib,setup_srv,setup_sup,setup_zomp,
testapp_app,testapp_sup,testapp_app,testapp_sup,
hex_api,hex_api_auth,hex_api_key,hex_api_organization,
hex_api_organization_member,hex_api_package,
hex_api_package_owner,hex_api_release,hex_api_user,
hex_core,hex_erl_tar,hex_filename,hex_http,
hex_http_httpc,hex_licenses,hex_pb_names,
hex_pb_package,hex_pb_signed,hex_pb_versions,
hex_registry,hex_repo,hex_tarball,safe_erl_term,pc,
pc_compilation,pc_port_env,pc_port_specs,pc_prv_clean,
pc_prv_compile,pc_util,rebar3_hex,rebar3_hex_app,
rebar3_hex_build,rebar3_hex_client,rebar3_hex_config,
rebar3_hex_cut,rebar3_hex_error,rebar3_hex_file,
rebar3_hex_httpc_adapter,rebar3_hex_io,rebar3_hex_key,
rebar3_hex_organization,rebar3_hex_owner,
rebar3_hex_publish,rebar3_hex_results,
rebar3_hex_retire,rebar3_hex_search,rebar3_hex_user,
rebar3_hex_version,
rebar_aecuckooprebuilt_app_with_priv_from_git_resource,
rebar_aecuckooprebuilt_dep,verl,verl_parser,base58,
eblake2,eblake2_tests,timing,enacl_eqc,enacl_ext_eqc,
enacl,enacl_ext,enacl_nif,enacl_SUITE,enoise,
enoise_cipher_state,enoise_connection,enoise_crypto,
enoise_hs_state,enoise_keypair,enoise_protocol,
enoise_sym_state,enoise_bad_data_tests,
enoise_chiper_state_tests,enoise_crypto_tests,
enoise_hs_state_tests,enoise_protocol_tests,
enoise_sym_state_tests,enoise_tests,enoise_utils,
test_utils,gmconfig,gmconfig_schema_helpers,
gmconfig_schema_utils,gmcuckoo,gmhp_msgs,
gmhw_blake2b_256,gmhw_pow,gmhw_pow_cuckoo,
gmhw_siphash24,gmcuckoo_SUITE,gmhw_pow_cuckoo_tests,
gmhw_pow_tests,gmser_api_encoder,gmser_chain_objects,
gmser_contract_code,gmser_delegation,gmser_dyn,
gmser_id,gmser_rlp,gmserialization,
gmser_api_encoder_tests,gmser_chain_objects_tests,
gmser_contract_code_tests,gmser_delegation_tests,
gmser_rlp_tests,gproc,gproc_app,gproc_bcast,
gproc_dist,gproc_info,gproc_init,gproc_lib,
gproc_monitor,gproc_pool,gproc_ps,gproc_pt,gproc_sup,
setup,setup_app,setup_file,setup_file_io_server,
setup_gen,setup_lib,setup_srv,setup_sup,setup_zomp,
testapp_app,testapp_sup,testapp_app,testapp_sup,
hex_api,hex_api_auth,hex_api_key,hex_api_organization,
hex_api_organization_member,hex_api_package,
hex_api_package_owner,hex_api_release,hex_api_user,
hex_core,hex_erl_tar,hex_filename,hex_http,
hex_http_httpc,hex_licenses,hex_pb_names,
hex_pb_package,hex_pb_signed,hex_pb_versions,
hex_registry,hex_repo,hex_tarball,safe_erl_term,pc,
pc_compilation,pc_port_env,pc_port_specs,pc_prv_clean,
pc_prv_compile,pc_util,rebar3_hex,rebar3_hex_app,
rebar3_hex_build,rebar3_hex_client,rebar3_hex_config,
rebar3_hex_cut,rebar3_hex_error,rebar3_hex_file,
rebar3_hex_httpc_adapter,rebar3_hex_io,rebar3_hex_key,
rebar3_hex_organization,rebar3_hex_owner,
rebar3_hex_publish,rebar3_hex_results,
rebar3_hex_retire,rebar3_hex_search,rebar3_hex_user,
rebar3_hex_version,
rebar_aecuckooprebuilt_app_with_priv_from_git_resource,
rebar_aecuckooprebuilt_dep,verl,verl_parser,gmhc_app,
gmhc_config,gmhc_config_schema,gmhc_connector,
gmhc_connectors_sup,gmhc_counters,gmhc_eureka,
gmhc_events,gmhc_handler,gmhc_server,gmhc_sup,
gmhc_workers,gmhive_client]},
{maintainers,["QPQ IaaS AG"]}, {maintainers,["QPQ IaaS AG"]},
{licensens,["ISC"]}, {licensens,["ISC"]},
{links,[{"gitea","https://git.qpq.swiss/gmhive_client"}]}]}. {links,[{"gitea","https://git.qpq.swiss/gmhive_client"}]}]}.

View File

@ -3,9 +3,9 @@
, pool => #{id => <<"ct_26xqeE3YKmZV8jrks57JSgZRCHSuG4RGzpnvdz6AAiSSTVbJRM">>, , pool => #{id => <<"ct_26xqeE3YKmZV8jrks57JSgZRCHSuG4RGzpnvdz6AAiSSTVbJRM">>,
host => <<"127.0.0.1">>} host => <<"127.0.0.1">>}
, workers => , workers =>
[#{executable => <<"mean15-generic">>, <<"executable_group">> => <<"gmcuckoo">>} [#{executable => <<"mean15-generic">>}
,#{executable => <<"mean15-generic">>, <<"executable_group">> => <<"gmcuckoo">>} ,#{executable => <<"mean15-generic">>}
,#{executable => <<"mean15-generic">>, <<"executable_group">> => <<"gmcuckoo">>} ,#{executable => <<"mean15-generic">>}
,#{executable => <<"mean15-generic">>, <<"executable_group">> => <<"gmcuckoo">>} ,#{executable => <<"mean15-generic">>}
] ]
}. }.

View File

@ -10,11 +10,11 @@
{gmhive_protocol, {gmhive_protocol,
{git, "https://git.qpq.swiss/QPQ-AG/gmhive_protocol.git", {git, "https://git.qpq.swiss/QPQ-AG/gmhive_protocol.git",
{ref, "818ce33"}}}, {ref, "818ce33"}}},
{gmhive_worker, {git, "https://git.qpq.swiss/QPQ-AG/gmhive_worker", {ref, "708f1a6"}}}, {gmhive_worker, {git, "https://git.qpq.swiss/QPQ-AG/gmhive_worker", {ref, "255ef59"}}},
{gmconfig, {git, "https://git.qpq.swiss/QPQ-AG/gmconfig.git", {gmconfig, {git, "https://git.qpq.swiss/QPQ-AG/gmconfig.git",
{ref, "32c1ed5c4b"}}}, {ref, "38620ff9e2"}}},
{gproc, "1.0.0"}, {gproc, "1.0.0"},
{setup, {git, "https://github.com/uwiger/setup", {ref, "3ad83ed"}}} {setup, {git, "https://github.com/uwiger/setup", {ref, "d9b0b51"}}}
]}. ]}.
{relx, [ {relx, [

View File

@ -1,10 +1,5 @@
{"1.2.0", {"1.2.0",
[{<<"aecuckooprebuilt">>, [{<<"base58">>,
{aecuckooprebuilt_app_with_priv_from_git,
{git,"https://github.com/aeternity/cuckoo-prebuilt.git",
{ref,"90afb699dc9cc41d033a7c8551179d32b3bd569d"}}},
1},
{<<"base58">>,
{git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git", {git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
{ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}}, {ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}},
2}, 2},
@ -22,11 +17,11 @@
0}, 0},
{<<"gmconfig">>, {<<"gmconfig">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmconfig.git", {git,"https://git.qpq.swiss/QPQ-AG/gmconfig.git",
{ref,"32c1ed5c4bc0913adc175fb18b1c9251acc7b606"}}, {ref,"38620ff9e2289dff121377c382e4d5b08c719d87"}},
0}, 0},
{<<"gmcuckoo">>, {<<"gmcuckoo">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmcuckoo.git", {git,"https://git.qpq.swiss/QPQ-AG/gmcuckoo.git",
{ref,"9f3aef96d8660e83ef8b5a7ee64908060a8c6572"}}, {ref,"106e1cd2e4ff81286f6bc7d7c85f83bc20e14b82"}},
1}, 1},
{<<"gmhive_protocol">>, {<<"gmhive_protocol">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmhive_protocol.git", {git,"https://git.qpq.swiss/QPQ-AG/gmhive_protocol.git",
@ -34,7 +29,7 @@
0}, 0},
{<<"gmhive_worker">>, {<<"gmhive_worker">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmhive_worker", {git,"https://git.qpq.swiss/QPQ-AG/gmhive_worker",
{ref,"708f1a62f9584f874eb9436a974401b5d4272d9f"}}, {ref,"255ef59ccd7f795d2d25f2d0ebcf24e3251b6f36"}},
0}, 0},
{<<"gmserialization">>, {<<"gmserialization">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git", {git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git",
@ -43,7 +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,"3ad83ed3cade6780897d11f5f0d987012b93345b"}}, {ref,"d9b0b51505ff75c459f1ab62bd907ca5e3a32291"}},
0}]}. 0}]}.
[ [
{pkg_hash,[ {pkg_hash,[

View File

@ -2,7 +2,6 @@
-export([ load_config/0 -export([ load_config/0
, get_config/1 , get_config/1
, verify_cfg_props/1
]). ]).
-include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/logger.hrl").
@ -13,6 +12,7 @@ load_config() ->
gmconfig:load_user_config(report), gmconfig:load_user_config(report),
gmconfig:apply_os_env(), gmconfig:apply_os_env(),
gmconfig:process_plain_args(), gmconfig:process_plain_args(),
check_application_env(),
ok. ok.
instrument_gmconfig() -> instrument_gmconfig() ->
@ -31,37 +31,35 @@ gmconfig_env() ->
get_config(Path) -> get_config(Path) ->
gmconfig:get_config(Path, cpath(Path)). gmconfig:get_config(Path, cpath(Path)).
cpath([<<"pubkey">>]) -> [user_config, env(pubkey ) ]; check_application_env() ->
cpath([<<"extra_pubkeys">>]) -> [user_config, env(extra_pubkeys ), schema_default]; case lists:foldl(fun appl_env/2, #{}, env_keys()) of
cpath([<<"pool_admin">>, <<"url">>]) -> [user_config, env(pool_admin_url), schema_default]; C when map_size(C) == 0 ->
cpath([<<"workers">>]) -> [user_config, env(workers ), schema_default];
cpath(_) -> [user_config, schema_default].
env2cpath(pubkey ) -> [<<"pubkey">>];
env2cpath(extra_pubkeys ) -> [<<"extra_pubkeys">>];
env2cpath(pool_admin_url) -> [<<"pool_admin">>, <<"url">>];
env2cpath(workers ) -> [<<"workers">>].
verify_cfg_props(PropList) ->
Cfg = lists:foldl(
fun({K,V}, M) ->
CfgK = env2cpath(K),
gmconfig:merge_config_maps(M, to_cfg_map(CfgK, V))
end, #{}, PropList),
case gmconfig_schema_utils:valid(Cfg) of
Ok when is_map(Ok) ->
ok; ok;
Other -> C ->
error({invalid_config, Other}) gmconfig:update_config(C)
end.
appl_env(K, C) ->
case application:get_env(gmhive_client, K) of
{ok, V} -> appl_env(K, V, C);
undefined -> C
end. end.
to_cfg_map(K, V) -> appl_env(bin_dir_hook , H , C) -> set_bin_dir_hook(H), C;
to_cfg_map(K, V, #{}). appl_env(pubkey , K , C) -> C#{<<"pubkey">> => K};
appl_env(extra_pubkeys , Ks, C) -> C#{<<"extra_pubkeys">> => Ks};
appl_env(pool_admin_url, U , C) -> merge(C, #{<<"pool_admin">> => #{<<"url">> => U}});
appl_env(workers , Ws, C) -> C#{<<"workers">> => Ws}.
to_cfg_map([H], V, M) -> set_bin_dir_hook({Mod, F}) when is_atom(Mod), is_atom(F) ->
M#{H => V}; application:set_env(gmhive_worker, bin_dir_hook, {Mod, F}).
to_cfg_map([H|T], V, M) ->
M#{H => to_cfg_map(T, V, M)}.
env(K) -> env_keys() -> [pubkey, extra_pubkeys, pool_admin_url, workers, network, bin_dir_hook].
{env, gmhive_client, K}.
cpath([<<"pubkey">>]) -> [user_config ];
cpath([<<"extra_pubkeys">>]) -> [user_config, schema_default];
cpath([<<"pool_admin">>, <<"url">>]) -> [user_config, schema_default];
cpath([<<"workers">>]) -> [user_config, schema_default];
cpath(_) -> [user_config, schema_default].
merge(A, B) ->
gmconfig:merge_config_maps(A, B).

View File

@ -24,7 +24,8 @@ to_json() ->
schema() -> schema() ->
obj(schema_init(), obj(schema_init(),
#{ #{
pubkey => str(#{pattern => ?ACCOUNT_PATTERN}, network => str(#{ default => <<"mainnet">> })
, pubkey => str(#{pattern => ?ACCOUNT_PATTERN},
<<"Primary client pubkey">>) <<"Primary client pubkey">>)
, extra_pubkeys => array(#{ description => , extra_pubkeys => array(#{ description =>
<<"Additional worker pubkeys, sharing rewards">> <<"Additional worker pubkeys, sharing rewards">>
@ -52,7 +53,14 @@ pool() ->
pool_admin() -> pool_admin() ->
obj(#{ obj(#{
url => str(#{ default => <<"https://test.gajumining.com/api/workers/{CLIENT_ID}">> url => str(#{ default => <<"https://test.gajumining.com/api/workers/{CLIENT_ID}">>
, description => <<"URL of Eureka worker api">> }) , description => <<"URL of Eureka worker api">> }),
default_per_network =>
obj(#{
testnet =>
str(#{default => <<"https://test.gajumining.com/api/workers/{CLIENT_ID}">>})
, mainnet =>
str(#{default => <<"https://gajumining.com/api/workers/{CLIENT_ID}">>})
})
}). }).
workers() -> workers() ->
@ -65,17 +73,8 @@ workers() ->
#{executable => #{executable =>
str(#{default => <<"mean29-generic">>, str(#{default => <<"mean29-generic">>,
description => description =>
<<"Executable binary of the worker. Options are: \"mean29-generic\"" <<"Executable binary of the worker. Can be a fully qualified path, \n"
" (memory-intensive), " "but the software may apply default logic to locate a plain basename.">>}),
"\"mean29-avx2\" (memory-intensive, benefits from faster CPU supporting"
" AVX2 instructions), "
"\"lean29-generic\" (CPU-intensive, useful if memory-constrained), "
"\"lean29-avx2\" (CPU-intensive, useful if memory-constrained, benefits "
"from faster CPU supporting AVX2 instructions).">>}),
executable_group =>
str(#{description => <<"Group of executable binaries of the worker.">>,
enum => [ <<"aecuckoo">>, <<"aecuckooprebuilt">>, <<"gmcuckoo">>, <<"cuda">>, <<"gajumine">> ],
default => <<"aecuckoo">>}),
extra_args => extra_args =>
str(#{description => <<"Extra arguments to pass to the worker executable binary. " str(#{description => <<"Extra arguments to pass to the worker executable binary. "
"The safest choice is specifying no arguments i.e. empty string.">>, "The safest choice is specifying no arguments i.e. empty string.">>,

View File

@ -6,15 +6,27 @@
-include("gmhc_events.hrl"). -include("gmhc_events.hrl").
get_pool_address() -> get_pool_address() ->
URL0 = gmhc_config:get_config([<<"pool_admin">>, <<"url">>]), case gmconfig:find_config([<<"pool_admin">>, <<"url">>], [user_config]) of
{ok, URL0} ->
case expand_url(URL0) of case expand_url(URL0) of
<<"local">> -> <<"local">> ->
#{<<"address">> => <<"127.0.0.1">>, #{<<"address">> => <<"127.0.0.1">>,
<<"port">> => gmconfig:get_config([<<"pool">>, <<"port">>], [schema_default]), <<"port">> => gmconfig:get_config(
[<<"pool">>, <<"port">>], [schema_default]),
<<"pool_id">> => gmhc_config:get_config([<<"pool">>, <<"id">>]) }; <<"pool_id">> => gmhc_config:get_config([<<"pool">>, <<"id">>]) };
URL -> URL ->
?LOG_INFO("Trying to connect to ~p", [URL]), ?LOG_INFO("Trying to connect to ~p", [URL]),
connect1(URL) connect1(URL)
end;
undefined ->
Network = gmconfig:get_config([<<"network">>]),
URL0 = gmconfig:get_config([ <<"pool_admin">>
, <<"default_per_network">>
, Network ],
[schema_default]),
URL = expand_url(URL0),
?LOG_INFO("Using default for ~p: ~p", [Network, URL]),
connect1(URL)
end. end.
connect1(URL0) -> connect1(URL0) ->

View File

@ -102,13 +102,21 @@ handle_cast({from_pool, #{via := Connector,
#{candidate := Cand0}}}, #{candidate := Cand0}}},
#st{workers = Workers} = S) -> #st{workers = Workers} = S) ->
Cand = maps:put(via, Connector, decode_candidate_hash(Cand0)), Cand = maps:put(via, Connector, decode_candidate_hash(Cand0)),
%% ?LOG_DEBUG("Got new candidate; will mine it: ~p", [Cand]), ?LOG_DEBUG("Got new candidate; will mine it: ~p", [Cand]),
%%
%% We could check whether we have already received the candidate ...
%% For now, stop all workers, restart with new candidate %% For now, stop all workers, restart with new candidate
try
Workers1 = stop_workers(Workers), Workers1 = stop_workers(Workers),
{Workers2, Cand1} = assign_nonces(Workers1, Cand), {Workers2, Cand1} = assign_nonces(Workers1, Cand),
#st{candidate = Cand2} = S1 = maybe_request_nonces(S#st{candidate = Cand1}), #st{candidate = Cand2} = S1 = maybe_request_nonces(S#st{candidate = Cand1}),
NewWorkers = [spawn_worker(W, Cand2) || W <- Workers2], NewWorkers = [spawn_worker(W, Cand2) || W <- Workers2],
{noreply, S1#st{workers = NewWorkers}}; {noreply, S1#st{workers = NewWorkers}}
catch
Cat:Err:St ->
?LOG_ERROR("CAUGHT ~p:~p / ~p", [Cat, Err, St]),
{noreply, S}
end;
handle_cast({disconnected, Id}, #st{connected = Conn} = S) -> handle_cast({disconnected, Id}, #st{connected = Conn} = S) ->
?LOG_DEBUG("disconnected: ~p", [Id]), ?LOG_DEBUG("disconnected: ~p", [Id]),
Conn1 = maps:remove(Id, Conn), Conn1 = maps:remove(Id, Conn),
@ -122,9 +130,7 @@ handle_cast(_Msg, S) ->
{noreply, S}. {noreply, S}.
handle_info({'DOWN', MRef, process, Pid, Reason}, #st{ workers = Workers handle_info({'DOWN', MRef, process, Pid, Reason}, #st{ workers = Workers
, connected = Connected , connected = Connected} = S) ->
, working = Working} = S)
when ?CONNECTED(S), Working ->
%% ?LOG_DEBUG("DOWN from ~p: ~p", [Pid, Reason]), %% ?LOG_DEBUG("DOWN from ~p: ~p", [Pid, Reason]),
case lists:keyfind(Pid, #worker.pid, Workers) of case lists:keyfind(Pid, #worker.pid, Workers) of
#worker{mref = MRef} = W -> #worker{mref = MRef} = W ->
@ -240,9 +246,10 @@ handle_worker_result(Error, W, S) ->
report_solutions_(Solutions, W, S) -> report_solutions_(Solutions, W, S) ->
case report_solutions(Solutions, W, S) of case report_solutions(Solutions, W, S) of
ok -> ok ->
Ws = reset_worker(W, S#st.workers), %% Ws = reset_worker(W, S#st.workers),
Ws1 = stop_workers(Ws), %% Ws1 = stop_workers(Ws),
{stopped, S#st{workers = Ws1}}; %% {stopped, S#st{workers = Ws1}};
{continue, S};
continue -> continue ->
{continue, S}; {continue, S};
{error, _} -> {error, _} ->
@ -302,7 +309,9 @@ stop_workers_for_seq(Seq, Workers) ->
[stop_worker(W) || #worker{cand = #{seq := Seq1}} = W <- Workers, [stop_worker(W) || #worker{cand = #{seq := Seq1}} = W <- Workers,
Seq1 =:= Seq]. Seq1 =:= Seq].
stop_worker(#worker{pid = Pid, mref = MRef} = W) when is_pid(Pid) -> stop_worker(#worker{pid = Pid} = W) when is_pid(Pid) ->
MRef = erlang:monitor(process, Pid),
?LOG_DEBUG("Will stop worker ~p (MRef = ~p)", [Pid, MRef]),
exit(Pid, kill), exit(Pid, kill),
receive receive
{'EXIT', Pid, _} -> ok; {'EXIT', Pid, _} -> ok;

View File

@ -16,7 +16,7 @@
-include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/logger.hrl").
-define(DEFAULT_EXECUTABLE_GROUP , <<"gajumine">>). -define(DEFAULT_EXECUTABLE_GROUP , <<"gmhive">>).
-define(DEFAULT_EXTRA_ARGS , <<>>). -define(DEFAULT_EXTRA_ARGS , <<>>).
-define(DEFAULT_HEX_ENCODED_HEADER , false). -define(DEFAULT_HEX_ENCODED_HEADER , false).
-define(DEFAULT_REPEATS , 1). -define(DEFAULT_REPEATS , 1).
@ -55,7 +55,7 @@ generate_from_hash(Hash, Target, Nonce, Config, WorkerInstance) ->
build_worker_config(Config) when is_map(Config) -> build_worker_config(Config) when is_map(Config) ->
Exec = maps:get(<<"executable">>, Config), Exec = maps:get(<<"executable">>, Config),
ExecGroup = maps:get(<<"executable_group">>, Config, ?DEFAULT_EXECUTABLE_GROUP), ExecGroup = ?DEFAULT_EXECUTABLE_GROUP,
ExtraArgs = maps:get(<<"extra_args">>, Config, ?DEFAULT_EXTRA_ARGS), ExtraArgs = maps:get(<<"extra_args">>, Config, ?DEFAULT_EXTRA_ARGS),
HexEncHdr = maps:get(<<"hex_encoded_header">>, Config, HexEncHdr = maps:get(<<"hex_encoded_header">>, Config,
hex_encoding_default(ExecGroup, Exec)), hex_encoding_default(ExecGroup, Exec)),

View File

@ -4,8 +4,12 @@
{prefix,"gmhc"}. {prefix,"gmhc"}.
{desc,"Gajumaru Hive Client"}. {desc,"Gajumaru Hive Client"}.
{author,"Ulf Wiger, QPQ AG"}. {author,"Ulf Wiger, QPQ AG"}.
{package_id,{"uwiger","gmhive_client",{0,2,1}}}. {package_id,{"uwiger","gmhive_client",{0,4,1}}}.
{deps,[{"uwiger","gmhive_worker",{0,1,1}}, {deps,[{"uwiger","gmcuckoo",{1,2,2}},
{"uwiger","gmhive_worker",{0,3,0}},
{"otpr","eblake2",{1,0,1}},
{"otpr","base58",{0,1,1}},
{"otpr","gmserialization",{0,1,3}},
{"uwiger","gmhive_protocol",{0,1,1}}, {"uwiger","gmhive_protocol",{0,1,1}},
{"uwiger","setup",{2,2,4}}, {"uwiger","setup",{2,2,4}},
{"uwiger","gproc",{1,0,1}}, {"uwiger","gproc",{1,0,1}},