Remove hut, use logger directly, with domain
This commit is contained in:
parent
c788653d17
commit
720f5600d4
@ -1,5 +1,4 @@
|
|||||||
{deps, [
|
{deps, [
|
||||||
{hut, "1.3.0"},
|
|
||||||
|
|
||||||
%% Cuckoo prebuilt CUDA binaries.
|
%% Cuckoo prebuilt CUDA binaries.
|
||||||
{aecuckooprebuilt,
|
{aecuckooprebuilt,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{"1.1.0",
|
{"1.2.0",
|
||||||
[{<<"aecuckoo">>,
|
[{<<"aecuckoo">>,
|
||||||
{git,"https://github.com/aeternity/aecuckoo.git",
|
{git,"https://github.com/aeternity/aecuckoo.git",
|
||||||
{ref,"996ffcdb336f1c2254ea8e1b1a657b05b7ea4a81"}},
|
{ref,"996ffcdb336f1c2254ea8e1b1a657b05b7ea4a81"}},
|
||||||
@ -11,9 +11,8 @@
|
|||||||
{<<"enacl">>,
|
{<<"enacl">>,
|
||||||
{git,"https://github.com/aeternity/enacl.git",
|
{git,"https://github.com/aeternity/enacl.git",
|
||||||
{ref,"67fceef42c0d055570f2e67b571f8d1f8de2f204"}},
|
{ref,"67fceef42c0d055570f2e67b571f8d1f8de2f204"}},
|
||||||
0},
|
0}]}.
|
||||||
{<<"hut">>,{pkg,<<"hut">>,<<"1.3.0">>},0}]}.
|
|
||||||
[
|
[
|
||||||
{pkg_hash,[
|
{pkg_hash,[]},
|
||||||
{<<"hut">>, <<"71F2F054E657C03F959CF1ACC43F436EA87580696528CA2A55C8AFB1B06C85E7">>}]}
|
{pkg_hash_ext,[]}
|
||||||
].
|
].
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
[kernel,
|
[kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
enacl,
|
enacl,
|
||||||
hut,
|
|
||||||
aecuckoo,
|
aecuckoo,
|
||||||
aecuckooprebuilt
|
aecuckooprebuilt
|
||||||
]},
|
]},
|
||||||
|
@ -53,9 +53,13 @@
|
|||||||
]).
|
]).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-include_lib("hut/include/hut.hrl").
|
|
||||||
-include("aeminer.hrl").
|
-include("aeminer.hrl").
|
||||||
|
|
||||||
|
-define(logger_meta, #{domain => [gaj, pow_cuckoo]}).
|
||||||
|
-define(debug(Fmt, Args) , logger:debug(Fmt, Args, ?logger_meta)).
|
||||||
|
-define(info(Fmt, Args) , logger:info(Fmt, Args, ?logger_meta)).
|
||||||
|
-define(warning(Fmt, Args), logger:warning(Fmt, Args, ?logger_meta)).
|
||||||
|
|
||||||
-type hashable() :: aeminer_blake2b_256:hashable().
|
-type hashable() :: aeminer_blake2b_256:hashable().
|
||||||
|
|
||||||
-type hash() :: aeminer_blake2b_256:hash().
|
-type hash() :: aeminer_blake2b_256:hash().
|
||||||
@ -186,13 +190,13 @@ generate(Data, Target, Nonce, Config, Instance) when
|
|||||||
{ok, {nonce(), solution()}} | {error, no_solution} | {error, {runtime, term()}}.
|
{ok, {nonce(), solution()}} | {error, no_solution} | {error, {runtime, term()}}.
|
||||||
generate_from_hash(Hash, Target, Nonce, Config, Instance) ->
|
generate_from_hash(Hash, Target, Nonce, Config, Instance) ->
|
||||||
Hash64 = base64:encode_to_string(Hash),
|
Hash64 = base64:encode_to_string(Hash),
|
||||||
?log(debug, "Generating solution for data hash ~p and nonce ~p with target ~p.",
|
?debug("Generating solution for data hash ~p and nonce ~p with target ~p.",
|
||||||
[Hash, Nonce, Target]),
|
[Hash, Nonce, Target]),
|
||||||
case generate_int(Hash64, Nonce, Target, Config, Instance) of
|
case generate_int(Hash64, Nonce, Target, Config, Instance) of
|
||||||
{ok, Nonce1, Soln} ->
|
{ok, Nonce1, Soln} ->
|
||||||
{ok, {Nonce1, Soln}};
|
{ok, {Nonce1, Soln}};
|
||||||
{error, no_value} ->
|
{error, no_value} ->
|
||||||
?log(debug, "No cuckoo solution found", []),
|
?debug("No cuckoo solution found", []),
|
||||||
{error, no_solution};
|
{error, no_solution};
|
||||||
{error, Rsn} ->
|
{error, Rsn} ->
|
||||||
%% Exec failed (segfault, not found, etc.): let miner decide
|
%% Exec failed (segfault, not found, etc.): let miner decide
|
||||||
@ -262,7 +266,7 @@ generate_int(Hash, Nonce, Target, MinerBinDir, MinerBin, MinerExtraArgs,
|
|||||||
#config{repeats = Repeats0, edge_bits = EdgeBits}) ->
|
#config{repeats = Repeats0, edge_bits = EdgeBits}) ->
|
||||||
Repeats = integer_to_list(Repeats0),
|
Repeats = integer_to_list(Repeats0),
|
||||||
Args = ["-h", Hash, "-n", integer_to_list(Nonce), "-r", Repeats | string:tokens(MinerExtraArgs, " ")],
|
Args = ["-h", Hash, "-n", integer_to_list(Nonce), "-r", Repeats | string:tokens(MinerExtraArgs, " ")],
|
||||||
?log(info, "Executing cmd '~s ~s'", [MinerBin, lists:concat(lists:join(" ", Args))]),
|
?info("Executing cmd '~s ~s'", [MinerBin, lists:concat(lists:join(" ", Args))]),
|
||||||
Old = process_flag(trap_exit, true),
|
Old = process_flag(trap_exit, true),
|
||||||
try exec_run(MinerBin, MinerBinDir, Args) of
|
try exec_run(MinerBin, MinerBinDir, Args) of
|
||||||
{ok, Port, OsPid} ->
|
{ok, Port, OsPid} ->
|
||||||
@ -340,7 +344,7 @@ verify_proof_(Header, Solution, EdgeBits) ->
|
|||||||
end
|
end
|
||||||
catch
|
catch
|
||||||
throw:{error, Rsn} ->
|
throw:{error, Rsn} ->
|
||||||
?log(info, "Proof verification failed for ~p: ~p", [Solution, Rsn]),
|
?info("Proof verification failed for ~p: ~p", [Solution, Rsn]),
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -495,20 +499,20 @@ parse_generation_result(["Solution" ++ NonceValuesStr | Rest],
|
|||||||
stop_execution(OsPid),
|
stop_execution(OsPid),
|
||||||
case parse_nonce_str(NonceStr) of
|
case parse_nonce_str(NonceStr) of
|
||||||
{ok, Nonce} ->
|
{ok, Nonce} ->
|
||||||
?log(debug, "Solution found: ~p", [Soln]),
|
?debug("Solution found: ~p", [Soln]),
|
||||||
{ok, Nonce, Soln};
|
{ok, Nonce, Soln};
|
||||||
Err = {error, _} ->
|
Err = {error, _} ->
|
||||||
?log(debug, "Bad nonce: ~p", [Err]),
|
?debug("Bad nonce: ~p", [Err]),
|
||||||
Err
|
Err
|
||||||
end;
|
end;
|
||||||
{N, _} when N /= ?SOLUTION_SIZE ->
|
{N, _} when N /= ?SOLUTION_SIZE ->
|
||||||
?log(debug, "Solution has wrong length (~p) should be ~p", [N, ?SOLUTION_SIZE]),
|
?debug("Solution has wrong length (~p) should be ~p", [N, ?SOLUTION_SIZE]),
|
||||||
%% No nonce in solution, old miner exec?
|
%% No nonce in solution, old miner exec?
|
||||||
stop_execution(OsPid),
|
stop_execution(OsPid),
|
||||||
{error, bad_miner};
|
{error, bad_miner};
|
||||||
{_, false} ->
|
{_, false} ->
|
||||||
%% failed to meet target: go on, we may find another solution
|
%% failed to meet target: go on, we may find another solution
|
||||||
?log(debug, "Failed to meet target (~p)", [Target]),
|
?debug("Failed to meet target (~p)", [Target]),
|
||||||
parse_generation_result(Rest, State)
|
parse_generation_result(Rest, State)
|
||||||
end;
|
end;
|
||||||
parse_generation_result([_Msg | T], State) ->
|
parse_generation_result([_Msg | T], State) ->
|
||||||
@ -526,7 +530,7 @@ parse_nonce_str(S) ->
|
|||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
stop_execution(OsPid) ->
|
stop_execution(OsPid) ->
|
||||||
exec_kill(OsPid),
|
exec_kill(OsPid),
|
||||||
?log(debug, "Mining OS process ~p stopped", [OsPid]),
|
?debug("Mining OS process ~p stopped", [OsPid]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
@ -558,10 +562,10 @@ exec_run(Cmd, Dir, Args) ->
|
|||||||
Port = erlang:open_port(PortName, PortSettings),
|
Port = erlang:open_port(PortName, PortSettings),
|
||||||
case erlang:port_info(Port, os_pid) of
|
case erlang:port_info(Port, os_pid) of
|
||||||
{os_pid, OsPid} ->
|
{os_pid, OsPid} ->
|
||||||
?log(debug, "External mining process started with OS pid ~p", [OsPid]),
|
?debug("External mining process started with OS pid ~p", [OsPid]),
|
||||||
{ok, Port, OsPid};
|
{ok, Port, OsPid};
|
||||||
undefined ->
|
undefined ->
|
||||||
?log(warning, "External mining process finished before ~p could acquire the OS pid", [?MODULE]),
|
?warning("External mining process finished before ~p could acquire the OS pid", [?MODULE]),
|
||||||
{ok, Port, undefined}
|
{ok, Port, undefined}
|
||||||
end
|
end
|
||||||
catch
|
catch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user