<%=
amount_col_title =
- if @validator_set_apply_block > 0 do
+ if @is_show_snapshotted_data do
gettext("Current Stake Amount") <> "
(" <> gettext("Accounted Stake Amount") <> ")"
else
gettext("Current Stake Amount")
@@ -27,7 +27,7 @@
<%=
reward_col_title =
- if @pool.is_validator && @validator_set_apply_block > 0 do
+ if @is_show_snapshotted_data do
gettext("Potential Reward Percent") <> "
(" <> gettext("Current Reward Percent") <> ")"
else
gettext("Potential Reward Percent")
@@ -69,11 +69,11 @@
<%= format_token_amount(delegator.stake_amount, @token, symbol: false) %>
- <%= if @pool.is_validator && @validator_set_apply_block > 0 do %>
+ <%= if @is_show_snapshotted_data do %>
(
<%=
if delegator.snapshotted_stake_amount do
- format_token_amount(delegator.snapshotted_stake_amount, @token, symbol: false)
+ format_token_amount(delegator.snapshotted_stake_amount, @token, symbol: false)
else
0
end
@@ -84,7 +84,7 @@
<%= if delegator.reward_ratio do %>
<%= delegator.reward_ratio %>%
- <%= if @pool.is_validator && @validator_set_apply_block > 0 do %>
+ <%= if @is_show_snapshotted_data do %>
(
<%=
if delegator.snapshotted_reward_ratio do
diff --git a/apps/explorer/lib/explorer/staking/contract_state.ex b/apps/explorer/lib/explorer/staking/contract_state.ex
index 3a281bac9d..6c70149bec 100644
--- a/apps/explorer/lib/explorer/staking/contract_state.ex
+++ b/apps/explorer/lib/explorer/staking/contract_state.ex
@@ -25,7 +25,8 @@ defmodule Explorer.Staking.ContractState do
:staking_contract,
:validator_set_contract,
:block_reward_contract,
- :validator_set_apply_block
+ :validator_set_apply_block,
+ :is_snapshotted
]
defstruct [
@@ -92,7 +93,8 @@ defmodule Explorer.Staking.ContractState do
validator_set_contract: %{abi: validator_set_abi, address: validator_set_contract_address},
block_reward_contract: %{abi: block_reward_abi, address: block_reward_contract_address},
token_contract_address: token_contract_address,
- token: get_token(token_contract_address)
+ token: get_token(token_contract_address),
+ is_snapshotted: false
)
{:ok, state, {:continue, []}}
@@ -261,10 +263,16 @@ defmodule Explorer.Staking.ContractState do
})
if previous_epoch && previous_epoch != 0 && previous_epoch != global_responses.epoch_number do
- StakeSnapshotting.start_snapshoting(
- %{contracts: contracts, abi: abi, global_responses: global_responses},
- block_number
- )
+ with(
+ true <- :ets.insert(@table_name, is_snapshotted: false),
+ {:ok, _} <-
+ StakeSnapshotting.start_snapshoting(
+ %{contracts: contracts, abi: abi, global_responses: global_responses},
+ block_number
+ )
+ ) do
+ :ets.insert(@table_name, is_snapshotted: true)
+ end
end
Publisher.broadcast(:staking_update)
diff --git a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
index a4a09aeaf9..cbcf76e8c6 100644
--- a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
+++ b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
@@ -127,12 +127,11 @@ defmodule Explorer.Staking.StakeSnapshotting do
})
end)
- {:ok, _} =
- Chain.import(%{
- staking_pools: %{params: pool_entries, on_conflict: staking_pool_on_conflict()},
- staking_pools_delegators: %{params: delegator_entries, on_conflict: staking_pools_delegator_on_conflict()},
- timeout: :infinity
- })
+ Chain.import(%{
+ staking_pools: %{params: pool_entries, on_conflict: staking_pool_on_conflict()},
+ staking_pools_delegators: %{params: delegator_entries, on_conflict: staking_pools_delegator_on_conflict()},
+ timeout: :infinity
+ })
end
def transform_requests(minig_address) do