mirror of
https://github.com/Retropex/bitfeed.git
synced 2025-05-28 04:52:29 +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
|
case status do
|
||||||
# if node is connected and finished with the initial block download
|
# if node is connected and finished with the initial block download
|
||||||
{:ok, %{"initialblockdownload" => false}} ->
|
{:ok, %{"initialblockdownload" => false}} ->
|
||||||
IO.puts("Bitcoin Core connected and fully synced");
|
|
||||||
# notify all listening processes
|
# notify all listening processes
|
||||||
notify_listeners(listeners);
|
notify_listeners(listeners);
|
||||||
Process.send_after(self(), :check_status, 60 * 1000);
|
Process.send_after(self(), :check_status, 300 * 1000);
|
||||||
{:noreply, {host, port, status, creds, []}}
|
{:noreply, {host, port, status, creds, []}}
|
||||||
|
|
||||||
{:ok, %{"initialblockdownload" => true}} ->
|
{:ok, %{"initialblockdownload" => true}} ->
|
||||||
IO.puts("Bitcoin Core connected, waiting for initial block download");
|
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}}
|
{:noreply, {host, port, status, creds, listeners}}
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
IO.puts("Waiting to connect to Bitcoin Core");
|
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}}
|
{:noreply, {host, port, status, creds, listeners}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -305,7 +305,18 @@ defmodule BitcoinStream.Mempool do
|
|||||||
sync_queue(pid, tail)
|
sync_queue(pid, tail)
|
||||||
end
|
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
|
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");
|
IO.puts("Preparing mempool sync");
|
||||||
with {:ok, 200, %{"mempool_sequence" => sequence, "txids" => txns}} <- RPC.request(:rpc, "getrawmempool", [false, true]) do
|
with {:ok, 200, %{"mempool_sequence" => sequence, "txids" => txns}} <- RPC.request(:rpc, "getrawmempool", [false, true]) do
|
||||||
set_seq(pid, sequence);
|
set_seq(pid, sequence);
|
||||||
@ -327,7 +338,7 @@ defmodule BitcoinStream.Mempool do
|
|||||||
IO.puts("Pool sync failed");
|
IO.puts("Pool sync failed");
|
||||||
IO.inspect(err);
|
IO.inspect(err);
|
||||||
#retry after 30 seconds
|
#retry after 30 seconds
|
||||||
:timer.sleep(30000);
|
:timer.sleep(10000);
|
||||||
sync(pid)
|
sync(pid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user