Skip to content

Commit

Permalink
Merge pull request #5 from wowica/cleanup-logs
Browse files Browse the repository at this point in the history
Cleanup logs
  • Loading branch information
caike authored Jan 3, 2024
2 parents 9d351b7 + 9f15021 commit 4ba42b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
14 changes: 0 additions & 14 deletions config/runtime.exs

This file was deleted.

21 changes: 8 additions & 13 deletions lib/xogmios/chain_sync.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,21 @@ defmodule Xogmios.ChainSync do
{:error, :connection_timeout}
end

{:error, _} = error ->
{:error, reason} = error ->
Logger.warning("Error starting WebSockex process #{inspect(reason)}")
error
end
end

def send_frame(connection, frame) do
try do
case WebSockex.send_frame(connection, {:text, frame}) do
:ok -> :ok
{:error, _reason} = error -> error
:ok ->
:ok

{:error, reason} = error ->
Logger.warning("Error sending frame #{inspect(reason)}")
error
end
rescue
_ -> {:error, :connection_down}
Expand All @@ -92,10 +97,7 @@ defmodule Xogmios.ChainSync do
} = _message,
state
) do
Logger.info("Finding intersection...")

message = Messages.find_intersection(tip["slot"], tip["id"])

{:reply, {:text, message}, state}
end

Expand All @@ -104,7 +106,6 @@ defmodule Xogmios.ChainSync do
state
) do
message = Messages.next_block()

{:reply, {:text, message}, state}
end

Expand Down Expand Up @@ -132,16 +133,11 @@ defmodule Xogmios.ChainSync do
end

defp handle_message(%{"method" => "findIntersection"}, state) do
Logger.info("Intersection found.")
Logger.info("Waiting for next block...")

message = Messages.next_block()

{:reply, {:text, message}, state}
end

defp handle_message(message, state) do
Logger.info("handle message: #{message}")
{:ok, state}
end

Expand All @@ -151,7 +147,6 @@ defmodule Xogmios.ChainSync do
end

def handle_disconnect(%{reason: {:local, reason}}, state) do
Logger.info("#{__MODULE__} local close with reason: #{inspect(reason)}")
{:ok, state}
end
end
Expand Down
18 changes: 16 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
defmodule Xogmios.MixProject do
use Mix.Project

@source_url "https://github.com/wowica/xogmios"
@version "0.0.1"

def project do
[
app: :xogmios,
version: "0.1.0",
version: @version,
elixir: "~> 1.16",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand All @@ -19,7 +22,11 @@ defmodule Xogmios.MixProject do
Xogmios.ClientExampleA,
Xogmios.ClientExampleB
]
]
],
package: package(),

# Docs
name: "Xogmios"
]
end

Expand All @@ -46,4 +53,11 @@ defmodule Xogmios.MixProject do
{:websockex, "~> 0.4.3"}
]
end

defp package do
[
maintainers: ["Carlos Souza"],
links: %{"GitHub" => @source_url}
]
end
end

0 comments on commit 4ba42b9

Please sign in to comment.