Fix schema typo + config, dialyzer stuff, add some events

This commit is contained in:
Ulf Wiger
2025-05-14 15:03:12 +02:00
parent c57d89ba3d
commit 0dca4bfaf8
9 changed files with 27 additions and 21 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ workers() ->
"from faster CPU supporting AVX2 instructions).">>}),
executable_group =>
str(#{description => <<"Group of executable binaries of the worker.">>,
enum => [ <<"aecuckoo">>, <<"aecuckooprebuilt">>, <<"gmcuckkoo">>, <<"cuda">>, <<"gajumine">> ],
enum => [ <<"aecuckoo">>, <<"aecuckooprebuilt">>, <<"gmcuckoo">>, <<"cuda">>, <<"gajumine">> ],
default => <<"aecuckoo">>}),
extra_args =>
str(#{description => <<"Extra arguments to pass to the worker executable binary. "
+9 -9
View File
@@ -57,9 +57,9 @@ request(get, URL, []) ->
HttpOpts = [{timeout, 15000}],
Opts = [],
Profile = default,
request_result(httpc:request(get, {URL, Headers}, HttpOpts, Opts, Profile));
request(post, URL, Body) ->
post_request(URL, Body).
request_result(httpc:request(get, {URL, Headers}, HttpOpts, Opts, Profile)).
%% request(post, URL, Body) ->
%% post_request(URL, Body).
expand_url(URL) ->
case re:run(URL, <<"{[^}]+}">>, []) of
@@ -122,12 +122,12 @@ get_var_name(<<H, T/binary>>, Acc) ->
%% From gmplugin_web_demo_handler.erl ===================================
post_request(URL, Map) ->
?LOG_DEBUG("Map = ~p", [Map]),
Body = json:encode(Map),
?LOG_DEBUG("Body = ~s", [Body]),
PostRes = httpc:request(post, {URL, [], "application/json", Body}, [], []),
request_result(PostRes).
%% post_request(URL, Map) ->
%% ?LOG_DEBUG("Map = ~p", [Map]),
%% Body = json:encode(Map),
%% ?LOG_DEBUG("Body = ~s", [Body]),
%% PostRes = httpc:request(post, {URL, [], "application/json", Body}, [], []),
%% request_result(PostRes).
%% ======================================================================
+4
View File
@@ -13,6 +13,8 @@
-type event() :: pool_notification
| {pool_notification, atom()}
| error
| puzzle
| result
| connected
| disconnected.
@@ -61,6 +63,8 @@ debug() ->
subscribe(pool_notification),
subscribe({pool_notification, new_generation}),
subscribe(connected),
subscribe(puzzle),
subscribe(result),
subscribe(error),
subscribe(disconnected),
loop()
+2
View File
@@ -365,8 +365,10 @@ spawn_worker(#worker{pid = undefined, nonce = Nonce, config = Cfg} = W, Cand) ->
-spec init_worker(binary(), integer(), integer(), tuple(), pid()) -> no_return().
init_worker(Data, Nonce, Target, Config, Parent) ->
gmhc_events:publish(puzzle, {Data, Target, Nonce, Config}),
Res = gmhc_workers:generate_from_hash(Data, Target, Nonce, Config, undefined),
%% ?LOG_DEBUG("worker result: ~p", [Res]),
gmhc_events:publish(result, Res),
case Res of
{ok, Solutions} when is_list(Solutions) ->
worker_result(Parent, {solutions, Solutions});