Interface update. v0.4.0
This commit is contained in:
parent
54a70d4b0b
commit
5b95daa27e
@ -196,11 +196,10 @@ handle_info(Unexpected, State) ->
|
|||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
gproc_ps_event(Info = {disconnect, #{info := #{reconnecting := false, error := #{code := Code, message := Message}}}}) ->
|
gproc_ps_event(Info = {disconnected, #{info := #{reconnecting := false, error := #{code := Code, message := Message}}}}) ->
|
||||||
ok = log(error, "Error terminal event received. Code: ~p. Message: ~p", [Code, Message]),
|
ok = log(error, "Error terminal event received. Code: ~p. Message: ~p", [Code, Message]),
|
||||||
Outcome = application:stop(gmhive_client),
|
ok = gmc_gui:message(Info),
|
||||||
ok = log(info, "application:stop(gmhivie_client) -> ~p", [Outcome]),
|
gmc_gui:start_stop();
|
||||||
gmc_gui:message(Info);
|
|
||||||
gproc_ps_event(Info) ->
|
gproc_ps_event(Info) ->
|
||||||
gmc_gui:message(Info).
|
gmc_gui:message(Info).
|
||||||
|
|
||||||
@ -229,7 +228,7 @@ do_stop() ->
|
|||||||
|
|
||||||
do_start_stop(State = #s{toggle = {Last, TS}}) ->
|
do_start_stop(State = #s{toggle = {Last, TS}}) ->
|
||||||
Now = erlang:system_time(second),
|
Now = erlang:system_time(second),
|
||||||
Clicklimit = Now - 5,
|
Clicklimit = Now - 1,
|
||||||
case TS < Clicklimit of
|
case TS < Clicklimit of
|
||||||
true ->
|
true ->
|
||||||
case Last of
|
case Last of
|
||||||
@ -286,6 +285,7 @@ do_start(State = #s{acc = PubKey, keys = Keys, network = Network, max_cores = Ma
|
|||||||
|
|
||||||
|
|
||||||
do_stop(State) ->
|
do_stop(State) ->
|
||||||
|
ok = gmc_gui:message({notice, "Stopping."}),
|
||||||
ok =
|
ok =
|
||||||
case application:stop(gmhive_client) of
|
case application:stop(gmhive_client) of
|
||||||
ok -> ok;
|
ok -> ok;
|
||||||
|
|||||||
@ -213,9 +213,34 @@ done(State = #s{net = Network, acc = AccTx, keys = KeysTx, cores = CoresTx, memo
|
|||||||
MOAR_IDs = wxTextCtrl:getValue(KeysTx),
|
MOAR_IDs = wxTextCtrl:getValue(KeysTx),
|
||||||
CoreS = wxTextCtrl:getValue(CoresTx),
|
CoreS = wxTextCtrl:getValue(CoresTx),
|
||||||
GigsS = wxTextCtrl:getValue(MemTx),
|
GigsS = wxTextCtrl:getValue(MemTx),
|
||||||
ok = gmc_con:conf({Net, list_to_binary(AccID), binify_keys(MOAR_IDs), cores(CoreS), bytes(GigsS)}),
|
ok = gmc_con:conf({Net, list_to_binary(AccID), binify_keys(AccID, MOAR_IDs), cores(CoreS), bytes(GigsS)}),
|
||||||
buh_bye(State).
|
buh_bye(State).
|
||||||
|
|
||||||
|
|
||||||
|
% NOTE: 32 is space, 12288 is full-width space.
|
||||||
|
binify_keys(AccID, MOAR) ->
|
||||||
|
Unwashed = lists:usort([K || K <- string:lexemes(MOAR, [$\r, $\n, 32, 12288, $\t, $,, $;])]),
|
||||||
|
Scrubbed = lists:delete(AccID, Unwashed),
|
||||||
|
Keys =
|
||||||
|
case lists:partition(fun is_key/1, Scrubbed) of
|
||||||
|
{Cleaned, []} ->
|
||||||
|
Cleaned;
|
||||||
|
{Cleaned, Trash} ->
|
||||||
|
Message = io_lib:format("The following keys are invalid:~n~p", [Trash]),
|
||||||
|
ok = gmc_gui:message({notice, Message}),
|
||||||
|
Cleaned
|
||||||
|
end,
|
||||||
|
lists:map(fun list_to_binary/1, Keys).
|
||||||
|
|
||||||
|
is_key(Mystery) ->
|
||||||
|
try
|
||||||
|
{account_pubkey, _} = gmser_api_encoder:decode(Mystery),
|
||||||
|
true
|
||||||
|
catch
|
||||||
|
_:_ -> false
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
cores("") ->
|
cores("") ->
|
||||||
2;
|
2;
|
||||||
cores(CoreS) ->
|
cores(CoreS) ->
|
||||||
@ -225,6 +250,7 @@ cores(CoreS) ->
|
|||||||
_:_ -> 2
|
_:_ -> 2
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
bytes("") ->
|
bytes("") ->
|
||||||
3550722201;
|
3550722201;
|
||||||
bytes(GigsS) ->
|
bytes(GigsS) ->
|
||||||
@ -240,11 +266,6 @@ bytes(GigsS) ->
|
|||||||
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, $,, $;])]).
|
|
||||||
|
|
||||||
|
|
||||||
acc(none) -> "";
|
acc(none) -> "";
|
||||||
acc(AKID) -> AKID.
|
acc(AKID) -> AKID.
|
||||||
|
|
||||||
|
|||||||
@ -303,22 +303,7 @@ do_message({connected, _}, State) ->
|
|||||||
Entry = "\nConnected",
|
Entry = "\nConnected",
|
||||||
do_message2(Entry, State);
|
do_message2(Entry, State);
|
||||||
do_message({disconnected, #{info := #{error := #{code := Code, message := Message}}}}, State = #s{}) ->
|
do_message({disconnected, #{info := #{error := #{code := Code, message := Message}}}}, State = #s{}) ->
|
||||||
% -32000 -> % mining_disabled
|
Format = "~nAn issue has been reported by the Hive Leader.~nError code: ~p '~s'",
|
||||||
% -32001 -> % nyi
|
|
||||||
% -32002 -> % pool_not_found
|
|
||||||
% -32003 -> % pool_exists
|
|
||||||
% -32004 -> % unknown_contract
|
|
||||||
% -32005 -> % invalid_prefix
|
|
||||||
% -32006 -> % invalid_encoding
|
|
||||||
% -32007 -> % outdated
|
|
||||||
% -32008 -> % solution_mismatch
|
|
||||||
% -32009 -> % invalid_input
|
|
||||||
% -32010 -> % session_limit
|
|
||||||
% -32011 -> % accounts_limit
|
|
||||||
% -32012 -> % duplicate_accounts
|
|
||||||
% -32601 -> % unknown_method
|
|
||||||
% -32603 -> % internal error
|
|
||||||
Format = "~nAn issue has been reported by the Hive Leader.~nError code: ~p '~s'~nStopping.",
|
|
||||||
Entry = io_lib:format(Format, [Code, Message]),
|
Entry = io_lib:format(Format, [Code, Message]),
|
||||||
do_message2(Entry, State);
|
do_message2(Entry, State);
|
||||||
do_message({disconnected, _}, State) ->
|
do_message({disconnected, _}, State) ->
|
||||||
@ -396,11 +381,12 @@ add_message2(Entry, {OMax, 0, IMax, 0, []}) ->
|
|||||||
{append, {OMax, 1, IMax, 1, [[Entry]]}}.
|
{append, {OMax, 1, IMax, 1, [[Entry]]}}.
|
||||||
|
|
||||||
|
|
||||||
start_stop(State = #s{buttons = Buttons, toggle = Last, toggle_t = none}) ->
|
start_stop(State = #s{buttons = Buttons, toggle = Last, toggle_t = T}) ->
|
||||||
|
ok = cancel_timer(T),
|
||||||
#w{wx = SSB} = lists:keyfind(start_stop, #w.name, Buttons),
|
#w{wx = SSB} = lists:keyfind(start_stop, #w.name, Buttons),
|
||||||
_ = wxButton:disable(SSB),
|
_ = wxButton:disable(SSB),
|
||||||
ok = gmc_con:start_stop(),
|
ok = gmc_con:start_stop(),
|
||||||
Timer = erlang:send_after(5000, self(), toggle),
|
Timer = erlang:send_after(2000, self(), toggle),
|
||||||
Next =
|
Next =
|
||||||
case Last of
|
case Last of
|
||||||
stop -> start;
|
stop -> start;
|
||||||
@ -408,6 +394,9 @@ start_stop(State = #s{buttons = Buttons, toggle = Last, toggle_t = none}) ->
|
|||||||
end,
|
end,
|
||||||
State#s{toggle = Next, toggle_t = Timer}.
|
State#s{toggle = Next, toggle_t = Timer}.
|
||||||
|
|
||||||
|
cancel_timer(none) -> ok;
|
||||||
|
cancel_timer(Time) -> erlang:cancel_timer(Time).
|
||||||
|
|
||||||
|
|
||||||
toggle(State = #s{buttons = Buttons, toggle = Next, j = J}) ->
|
toggle(State = #s{buttons = Buttons, toggle = Next, j = J}) ->
|
||||||
#w{wx = SSB} = lists:keyfind(start_stop, #w.name, Buttons),
|
#w{wx = SSB} = lists:keyfind(start_stop, #w.name, Buttons),
|
||||||
|
|||||||
@ -5,9 +5,9 @@
|
|||||||
{prefix,"gmc"}.
|
{prefix,"gmc"}.
|
||||||
{desc,"Mining client for the Gajumaru Root"}.
|
{desc,"Mining client for the Gajumaru Root"}.
|
||||||
{package_id,{"qpq","gajumine",{0,4,0}}}.
|
{package_id,{"qpq","gajumine",{0,4,0}}}.
|
||||||
{deps,[{"otpr","zxwidgets",{1,1,0}},
|
{deps,[{"uwiger","gmhive_client",{0,10,0}},
|
||||||
|
{"otpr","zxwidgets",{1,1,0}},
|
||||||
{"otpr","hakuzaru",{0,7,0}},
|
{"otpr","hakuzaru",{0,7,0}},
|
||||||
{"uwiger","gmhive_client",{0,9,3}},
|
|
||||||
{"uwiger","gmhive_protocol",{0,2,0}},
|
{"uwiger","gmhive_protocol",{0,2,0}},
|
||||||
{"uwiger","gmcuckoo",{1,2,4}},
|
{"uwiger","gmcuckoo",{1,2,4}},
|
||||||
{"uwiger","gmhive_worker",{0,5,1}},
|
{"uwiger","gmhive_worker",{0,5,1}},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user