Load from saved state after crash.

This commit is contained in:
2026-02-11 20:29:40 -05:00
parent b917a0297c
commit 0e154f4ced

View File

@@ -156,6 +156,10 @@ defmodule Core.Bots.DCABot do
def init(%{symbol: symbol, restore_state: restore_state}) do
account_id = Core.Client.account_id()
# If no restore_state was explicitly provided, check if there's saved state for this symbol
restore_state =
restore_state || find_saved_state_for_symbol(symbol)
state =
if restore_state do
# Restoring from saved state
@@ -632,4 +636,12 @@ defmodule Core.Bots.DCABot do
false
end
end
defp find_saved_state_for_symbol(symbol) do
state_data = Core.Bots.BotPersistence.load_state()
Enum.find(state_data, fn bot_state ->
bot_state["symbol"] == symbol
end)
end
end