mirror of
https://github.com/Retropex/bitfeed.git
synced 2025-05-12 19:20:46 +02:00
API server startup tweaks for umbrel release
This commit is contained in:
parent
c0703a7a21
commit
561cc30aa6
@ -37,20 +37,19 @@ defmodule BitcoinStream.RPC do
|
||||
case status do
|
||||
# if node is connected and finished with the initial block download
|
||||
{:ok, %{"initialblockdownload" => false}} ->
|
||||
IO.puts("Bitcoin Core connected and fully synced");
|
||||
# notify all listening processes
|
||||
notify_listeners(listeners);
|
||||
Process.send_after(self(), :check_status, 60 * 1000);
|
||||
Process.send_after(self(), :check_status, 300 * 1000);
|
||||
{:noreply, {host, port, status, creds, []}}
|
||||
|
||||
{:ok, %{"initialblockdownload" => true}} ->
|
||||
IO.puts("Bitcoin Core connected, waiting for initial block download");
|
||||
Process.send_after(self(), :check_status, 60 * 1000);
|
||||
Process.send_after(self(), :check_status, 30 * 1000);
|
||||
{:noreply, {host, port, status, creds, listeners}}
|
||||
|
||||
_ ->
|
||||
IO.puts("Waiting to connect to Bitcoin Core");
|
||||
Process.send_after(self(), :check_status, 60 * 1000);
|
||||
Process.send_after(self(), :check_status, 10 * 1000);
|
||||
{:noreply, {host, port, status, creds, listeners}}
|
||||
end
|
||||
end
|
||||
|
@ -305,7 +305,18 @@ defmodule BitcoinStream.Mempool do
|
||||
sync_queue(pid, tail)
|
||||
end
|
||||
|
||||
defp wait_for_ibd() do
|
||||
case RPC.get_node_status(:rpc) do
|
||||
{:ok, %{"initialblockdownload" => false}} -> true
|
||||
|
||||
_ ->
|
||||
RPC.notify_on_ready(:rpc)
|
||||
end
|
||||
end
|
||||
|
||||
def sync(pid) do
|
||||
IO.puts("Waiting for node to come online and fully sync before synchronizing mempool");
|
||||
wait_for_ibd();
|
||||
IO.puts("Preparing mempool sync");
|
||||
with {:ok, 200, %{"mempool_sequence" => sequence, "txids" => txns}} <- RPC.request(:rpc, "getrawmempool", [false, true]) do
|
||||
set_seq(pid, sequence);
|
||||
@ -327,7 +338,7 @@ defmodule BitcoinStream.Mempool do
|
||||
IO.puts("Pool sync failed");
|
||||
IO.inspect(err);
|
||||
#retry after 30 seconds
|
||||
:timer.sleep(30000);
|
||||
:timer.sleep(10000);
|
||||
sync(pid)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user