From fe7115b0e270b5018028ccaf513630dc448b518d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 11 Sep 2019 16:11:10 +0300 Subject: [PATCH 1/4] fix exchange rate websocket update for Rootstock Rootstock has custom logic for market cap calculation that uses data from DB. This PR add required feilds to exchange_rate when sending it through a web socket. --- apps/block_scout_web/lib/block_scout_web/notifier.ex | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/notifier.ex b/apps/block_scout_web/lib/block_scout_web/notifier.ex index aa47163c98..03e46cf38b 100644 --- a/apps/block_scout_web/lib/block_scout_web/notifier.ex +++ b/apps/block_scout_web/lib/block_scout_web/notifier.ex @@ -7,6 +7,7 @@ defmodule BlockScoutWeb.Notifier do alias BlockScoutWeb.{AddressContractVerificationView, Endpoint} alias Explorer.{Chain, Market, Repo} alias Explorer.Chain.{Address, InternalTransaction, Transaction} + alias Explorer.Chain.Supply.RSK alias Explorer.Counters.AverageBlockTime alias Explorer.ExchangeRates.Token alias Explorer.SmartContract.{Solidity.CodeCompiler, Solidity.CompilerVersion} @@ -76,8 +77,17 @@ defmodule BlockScoutWeb.Notifier do data -> data end + exchange_rate_with_available_supply = + case Application.get_env(:explorer, :supply) do + RSK -> + %{exchange_rate | available_supply: RSK.circulating(), market_cap_usd: RSK.market_cap(exchange_rate)} + + _ -> + exchange_rate + end + Endpoint.broadcast("exchange_rate:new_rate", "new_rate", %{ - exchange_rate: exchange_rate, + exchange_rate: exchange_rate_with_available_supply, market_history_data: Enum.map(market_history_data, fn day -> Map.take(day, [:closing_price, :date]) end) }) end From df7c043d6a9c45959e2d83358b764e41bf9a7b7b Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 11 Sep 2019 16:14:51 +0300 Subject: [PATCH 2/4] add CHANGELOG entry --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c85224762..9084f2de1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Features - [#2665](https://github.com/poanetwork/blockscout/pull/2665) - new menu layout for mobile devices -- [#2679](https://github.com/poanetwork/blockscout/pull/2679) - added fixed height for card chain blocks and card chain transactions +- [#2679](https://github.com/poanetwork/blockscout/pull/2679) - added fixed height for card chain blocks and card chain transactions - [#2678](https://github.com/poanetwork/blockscout/pull/2678) - fixed dashboard banner height bug - [#2672](https://github.com/poanetwork/blockscout/pull/2672) - added new theme for xUSDT - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel @@ -10,7 +10,8 @@ ### Fixes - [#2684](https://github.com/poanetwork/blockscout/pull/2684) - do not filter pending logs - [#2682](https://github.com/poanetwork/blockscout/pull/2682) - Use Task.start instead of Task.async in caches -- [#2671](https://github.com/poanetwork/blockscout/pull/2671) - fixed buttons color at smart contract section +- [#2671](https://github.com/poanetwork/blockscout/pull/2671) - fixed buttons color at smart contract section +- [#2691](https://github.com/poanetwork/blockscout/pull/2691) - fix exchange rate websocket update for Rootstock ### Chore From 7c660b472ba894bf48fdf5460d75dc547ccde566 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 12 Sep 2019 12:49:18 +0300 Subject: [PATCH 3/4] do not update chart --- apps/block_scout_web/lib/block_scout_web/notifier.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/notifier.ex b/apps/block_scout_web/lib/block_scout_web/notifier.ex index 03e46cf38b..7c07c8524e 100644 --- a/apps/block_scout_web/lib/block_scout_web/notifier.ex +++ b/apps/block_scout_web/lib/block_scout_web/notifier.ex @@ -80,7 +80,7 @@ defmodule BlockScoutWeb.Notifier do exchange_rate_with_available_supply = case Application.get_env(:explorer, :supply) do RSK -> - %{exchange_rate | available_supply: RSK.circulating(), market_cap_usd: RSK.market_cap(exchange_rate)} + %{exchange_rate | available_supply: nil, market_cap_usd: RSK.market_cap(exchange_rate)} _ -> exchange_rate From 5d9f7d0c20528437e8976d55ad3dd7e804bd41ef Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 16 Sep 2019 17:53:35 +0300 Subject: [PATCH 4/4] Exclude nonconsensus blocks from avg block time calculation by default --- CHANGELOG.md | 1 + apps/explorer/config/config.exs | 2 +- docs/env-variables.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e0fd3e1b9..72877501b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel ### Fixes +- [#2701](https://github.com/poanetwork/blockscout/pull/2701) - Exclude nonconsensus blocks from avg block time calculation by default - [#2687](https://github.com/poanetwork/blockscout/pull/2687) - remove non-consensus token transfers, logs when inserting new consensus blocks - [#2684](https://github.com/poanetwork/blockscout/pull/2684) - do not filter pending logs - [#2682](https://github.com/poanetwork/blockscout/pull/2682) - Use Task.start instead of Task.async in caches diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index deefc9e3da..8a264eaf33 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -14,7 +14,7 @@ config :explorer, System.get_env("ALLOWED_EVM_VERSIONS") || "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg,default", include_uncles_in_average_block_time: - if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "false", do: false, else: true), + if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "true", do: true, else: false), healthy_blocks_period: System.get_env("HEALTHY_BLOCKS_PERIOD") || :timer.minutes(5) average_block_period = diff --git a/docs/env-variables.md b/docs/env-variables.md index 5eef49d07d..503689d091 100644 --- a/docs/env-variables.md +++ b/docs/env-variables.md @@ -56,6 +56,7 @@ $ export NETWORK=POA | `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ | | | | `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ | | | | `ALLOWED_EVM_VERSIONS ` | | the comma-separated list of allowed EVM versions for contracts verification. This var was introduced in [#1964](https://github.com/poanetwork/blockscout/pull/1964) | "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" | v2.0.0+ | | | +| `UNCLES_IN_AVERAGE_BLOCK_TIME` | Include or exclude nonconsensus blocks in avg block time calculation. Exclude if `false`. | false | v2.0.1+ | | | | `AVERAGE_BLOCK_CACHE_PERIOD` | | Update of average block cache, in seconds | 30 minutes | v2.0.2+ | | | `MARKET_HISTORY_CACHE_PERIOD` | | Update of market history cache, in seconds | 6 hours | v2.0.2+ | | | `DISABLE_WEBAPP` | | If `true`, endpoints to webapp are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: | |