WIP: Add message subscription

This commit is contained in:
Craig Everett 2025-05-13 22:57:08 +09:00
parent 8045853324
commit 5b93ebab93
2 changed files with 19 additions and 4 deletions

View File

@ -212,6 +212,9 @@ handle_cast(Unexpected, State) ->
{noreply, State}. {noreply, State}.
handle_info({gproc_ps_event, Event, Data}, State) ->
ok = gmc_gui:message({Event, Data}),
{noreply, State};
handle_info(Unexpected, State) -> handle_info(Unexpected, State) ->
ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]), ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]),
{noreply, State}. {noreply, State}.
@ -347,7 +350,10 @@ do_start_stop(#s{key = #key{id = PubKey}, network = Network}) ->
% Check memory. >7gb gets mean, <7gb gets lean % Check memory. >7gb gets mean, <7gb gets lean
% Check avx2. % Check avx2.
% Both should be provided by the F# start program % Both should be provided by the F# start program
{"mean", "avx2"} case Network of
<<"mainnet">> -> {"mean", "avx2.exe"};
<<"testnet">> -> {"mean", "generic.exe"}
end
end, end,
Miner = unicode:characters_to_binary([Fatness, Bits, "-", Type]), Miner = unicode:characters_to_binary([Fatness, Bits, "-", Type]),
Profile = Profile =
@ -355,7 +361,14 @@ do_start_stop(#s{key = #key{id = PubKey}, network = Network}) ->
{mining, [#{<<"executable">> => Miner, <<"executable_group">> => <<"gajumine">>}]}, {mining, [#{<<"executable">> => Miner, <<"executable_group">> => <<"gajumine">>}]},
{pool_admin_url, Eureka}], {pool_admin_url, Eureka}],
{ok, Apps} = gmmpc_app:start(Profile), {ok, Apps} = gmmpc_app:start(Profile),
log(info, "Apps started: ~p", [Apps]). ok = log(info, "Apps started: ~p", [Apps]),
Events =
[pool_notification,
{pool_notification, new_generation},
connected,
error,
disconnected],
lists:foreach(fun gmmpc_events:ensure_subscribed/1, Events).
%%% Utils %%% Utils

View File

@ -260,7 +260,7 @@ candidate(Block, #s{candy = Widget}) ->
do_message(Terms, State = #s{mess = Mess, buff = Buff}) -> do_message(Terms, State = #s{mess = Mess, buff = Buff}) ->
Entry = io_lib:format("Received args: ~tp~n", [Terms]), Entry = io_lib:format("~tp~n", [Terms]),
NewBuff = add_message(Entry, Buff), NewBuff = add_message(Entry, Buff),
String = unicode:characters_to_list(element(5, NewBuff)), String = unicode:characters_to_list(element(5, NewBuff)),
ok = wxTextCtrl:changeValue(Mess, String), ok = wxTextCtrl:changeValue(Mess, String),
@ -273,7 +273,9 @@ add_message(Entry, {OMax, OMax, IMax, ICur, [H | Buff]}) ->
add_message(Entry, {OMax, OCur, IMax, IMax, Buff}) -> add_message(Entry, {OMax, OCur, IMax, IMax, Buff}) ->
{OMax, OCur + 1, IMax, 1, [[Entry] | Buff]}; {OMax, OCur + 1, IMax, 1, [[Entry] | Buff]};
add_message(Entry, {OMax, OCur, IMax, ICur, [H | Buff]}) -> add_message(Entry, {OMax, OCur, IMax, ICur, [H | Buff]}) ->
{OMax, OCur, IMax, ICur + 1, [[Entry | H] | Buff]}. {OMax, OCur, IMax, ICur + 1, [[Entry | H] | Buff]};
add_message(Entry, {OMax, 0, IMax, 0, []}) ->
{OMax, 1, IMax, 1, [[Entry]]}.
start_stop(State) -> start_stop(State) ->