Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some display / API issue #600

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion lib/archethic/metrics/poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ defmodule Archethic.Metrics.Poller do
http_port: port,
first_public_key: first_public_key
} ->
{first_public_key, Collector.fetch_metrics(ip, port)}
if first_public_key == Archethic.Crypto.first_node_public_key(),
do: {first_public_key, Collector.fetch_metrics({127, 0, 0, 1}, port)},
else: {first_public_key, Collector.fetch_metrics(ip, port)}
end,
on_timeout: :kill_task
)
Expand Down
8 changes: 4 additions & 4 deletions lib/archethic/p2p/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,14 @@ defmodule Archethic.P2P.Message do
token_balances_binary =
token_balances
|> Enum.reduce([], fn {{token_address, token_id}, amount}, acc ->
[<<token_address::binary, amount::float, VarInt.from_value(token_id)::binary>> | acc]
[<<token_address::binary, amount::64, VarInt.from_value(token_id)::binary>> | acc]
end)
|> Enum.reverse()
|> :erlang.list_to_binary()

encoded_token_balances_length = map_size(token_balances) |> VarInt.from_value()

<<248::8, uco_balance::float, encoded_token_balances_length::binary,
<<248::8, uco_balance::64, encoded_token_balances_length::binary,
token_balances_binary::binary>>
end

Expand Down Expand Up @@ -1084,7 +1084,7 @@ defmodule Archethic.P2P.Message do
}, rest}
end

def decode(<<248::8, uco_balance::float, rest::bitstring>>) do
def decode(<<248::8, uco_balance::64, rest::bitstring>>) do
{nb_token_balances, rest} = rest |> VarInt.get_value()
{token_balances, rest} = deserialize_token_balances(rest, nb_token_balances, %{})

Expand Down Expand Up @@ -1200,7 +1200,7 @@ defmodule Archethic.P2P.Message do
end

defp deserialize_token_balances(rest, nb_token_balances, acc) do
{token_address, <<amount::float, rest::bitstring>>} = Utils.deserialize_address(rest)
{token_address, <<amount::64, rest::bitstring>>} = Utils.deserialize_address(rest)
{token_id, rest} = VarInt.get_value(rest)

deserialize_token_balances(
Expand Down
2 changes: 1 addition & 1 deletion lib/archethic_web/live/chains/oracle_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ defmodule ArchethicWeb.OracleChainLive do
} ->
%{address: address, type: type, timestamp: timestamp}
end)
|> Enum.to_list()
|> Enum.reverse()
end

defp list_transactions_by_date(nil), do: []
Expand Down