fix cardinality error issue

pull/1423/head
Ayrat Badykov 6 years ago
parent 67ee2af326
commit 0be39ea2ec
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 22
      apps/indexer/lib/indexer/block/reward/fetcher.ex

@ -177,18 +177,20 @@ defmodule Indexer.Block.Reward.Fetcher do
|> Enum.map(& &1.block_hash) |> Enum.map(& &1.block_hash)
|> Chain.gas_payment_by_block_hash() |> Chain.gas_payment_by_block_hash()
beneficiaries_params Enum.map(beneficiaries_params, fn %{block_hash: block_hash, address_type: address_type} = beneficiary ->
|> Enum.map(fn %{block_hash: block_hash} = beneficiary -> if address_type == :validator do
case gas_payment_by_block_hash do case gas_payment_by_block_hash do
%{^block_hash => gas_payment} -> %{^block_hash => gas_payment} ->
{:ok, minted} = Wei.cast(beneficiary.reward) {:ok, minted} = Wei.cast(beneficiary.reward)
%{beneficiary | reward: Wei.sum(minted, gas_payment)} %{beneficiary | reward: Wei.sum(minted, gas_payment)}
_ -> _ ->
beneficiary beneficiary
end
else
beneficiary
end end
end) end)
|> Enum.uniq()
end end
defp import_block_reward_params(block_rewards_params) when is_list(block_rewards_params) do defp import_block_reward_params(block_rewards_params) when is_list(block_rewards_params) do

Loading…
Cancel
Save