From 0be39ea2ec1abe0968d9f8dc035de4695c14ffb5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 11 Feb 2019 17:18:36 +0300 Subject: [PATCH] fix cardinality error issue --- .../lib/indexer/block/reward/fetcher.ex | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/indexer/lib/indexer/block/reward/fetcher.ex b/apps/indexer/lib/indexer/block/reward/fetcher.ex index fe1d5d2bf2..0c190f9719 100644 --- a/apps/indexer/lib/indexer/block/reward/fetcher.ex +++ b/apps/indexer/lib/indexer/block/reward/fetcher.ex @@ -177,18 +177,20 @@ defmodule Indexer.Block.Reward.Fetcher do |> Enum.map(& &1.block_hash) |> Chain.gas_payment_by_block_hash() - beneficiaries_params - |> Enum.map(fn %{block_hash: block_hash} = beneficiary -> - case gas_payment_by_block_hash do - %{^block_hash => gas_payment} -> - {:ok, minted} = Wei.cast(beneficiary.reward) - %{beneficiary | reward: Wei.sum(minted, gas_payment)} - - _ -> - beneficiary + Enum.map(beneficiaries_params, fn %{block_hash: block_hash, address_type: address_type} = beneficiary -> + if address_type == :validator do + case gas_payment_by_block_hash do + %{^block_hash => gas_payment} -> + {:ok, minted} = Wei.cast(beneficiary.reward) + %{beneficiary | reward: Wei.sum(minted, gas_payment)} + + _ -> + beneficiary + end + else + beneficiary end end) - |> Enum.uniq() end defp import_block_reward_params(block_rewards_params) when is_list(block_rewards_params) do