Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: catch error when post_partial_solution #675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions apps/arweave/src/ar_http_iface_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -686,20 +686,30 @@ get_jobs(Peer, PrevOutput) ->
"/jobs/" ++ binary_to_list(ar_util:encode(PrevOutput))),
handle_get_jobs_response(ar_http:req(Req)).

serialize_solution(Solution) ->
Json = ar_serialize:solution_to_json_struct(Solution),
{ok, ar_serialize:jsonify(Json)}.

serialize_solution_ify(Solution) ->
case is_binary(Solution) of
true ->
{ok, Solution};
false ->
serialize_solution(Solution)
end.

%% @doc Post the partial solution to the pool or coordinated mining exit peer.
post_partial_solution(Peer, Solution) ->
Payload =
case is_binary(Solution) of
true ->
Solution;
false ->
ar_serialize:jsonify(ar_serialize:solution_to_json_struct(Solution))
end,
Req = build_cm_or_pool_request(post, Peer, "/partial_solution", Payload),
handle_post_partial_solution_response(ar_http:req(Req#{
timeout => 20 * 1000,
connect_timeout => 5 * 1000
})).
case catch serialize_solution_ify(Solution) of
{ok, Payload} ->
Req = build_cm_or_pool_request(post, Peer, "/partial_solution", Payload),
handle_post_partial_solution_response(ar_http:req(Req#{
timeout => 20 * 1000,
connect_timeout => 5 * 1000
}));
{'EXIT', Reason, _ } -> {error, Reason};
_ -> {error, failed_to_serialize_partial_solution}
end.

get_pool_cm_jobs(Peer, Jobs) ->
JSON = ar_serialize:jsonify(ar_serialize:pool_cm_jobs_to_json_struct(Jobs)),
Expand Down