Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Fix fastforward CLI #1504

Merged
merged 1 commit into from
Jan 10, 2023
Merged
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
17 changes: 15 additions & 2 deletions src/cli/blockchain_cli_peer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,21 @@ peer_fastforward(["peer", "fastforward", Addr], [], []) ->
SwarmTID = blockchain_swarm:tid(),
TrimmedAddr = string:trim(Addr),
case blockchain_fastforward_handler:dial(SwarmTID, Chain, TrimmedAddr) of
{ok, _Pid} ->
[clique_status:text("ok")];
{ok, Stream} ->
Ref = erlang:monitor(process, Stream),
%% sleep for a moment because there can be a race in monitor
timer:sleep(100),
receive
{'DOWN', Ref, process, Stream, normal} ->
%% we're done, nothing to do here.
[clique_status:text("ok")];
{'DOWN', Ref, process, Stream, Reason} ->
Text = io_lib:format("fastforward failed with error ~p", [Reason]),
[clique_status:text(Text)]
after timer:minutes(application:get_env(blockchain, sync_timeout_mins, 5)) ->
libp2p_framed_stream:close(Stream),
[clique_status:text("fastforward timeout")]
end;
{error, Reason} ->
Text = io_lib:format("Failed to connect to ~p: ~p", [TrimmedAddr, Reason]),
[clique_status:alert([clique_status:text(Text)])]
Expand Down