Commit deb683ac authored by Sondre Bjellås's avatar Sondre Bjellås

Minor fix to avoid duplicate calls of timer startup

- Retrieving the blockchain stat and marketcap info was set to run in a manner that could trigger it multiple times, and if the initial page launched was the explorer, it could sometimes crash as the "BlockchainStats" was not in cache.
- Rename the docker-compose, was invalid named.
parent 8e1aa96a
...@@ -8,7 +8,7 @@ services: ...@@ -8,7 +8,7 @@ services:
image: coinvault/nako image: coinvault/nako
command: stratis command: stratis
ports: ports:
- 9040:9000 - 9030:9000
depends_on: depends_on:
- mongo - mongo
- client - client
...@@ -20,7 +20,7 @@ services: ...@@ -20,7 +20,7 @@ services:
image: stratisplatform/fullnode:StratisMain image: stratisplatform/fullnode:StratisMain
command: ["dotnet", "run", "--", "-server=1", "-rpcallowip=172.16.11.100", "-rpcbind=172.16.11.101", "-rpcport=5000", "-rpcuser=rpcuser", "-rpcpassword=rpcpassword", "-rpcthreads=300", "-txindex=1"] command: ["dotnet", "run", "--", "-server=1", "-rpcallowip=172.16.11.100", "-rpcbind=172.16.11.101", "-rpcport=5000", "-rpcuser=rpcuser", "-rpcpassword=rpcpassword", "-rpcthreads=300", "-txindex=1"]
ports: ports:
- 5040:5000 - 5030:5000
- 16178:16178 - 16178:16178
mongo: mongo:
container_name: stratis-mongo container_name: stratis-mongo
......
...@@ -32,11 +32,16 @@ namespace Stratis.Guru.Services ...@@ -32,11 +32,16 @@ namespace Stratis.Guru.Services
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
{ {
_updateTimer.Interval = 10; _updateTimer.AutoReset = false; // Make sure it only trigger once initially.
_updateTimer.Enabled = true;
_updateTimer.Elapsed += async (sender, args) => _updateTimer.Elapsed += async (sender, args) =>
{ {
_updateTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds; if (_updateTimer.AutoReset == false)
{
_updateTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds;
_updateTimer.AutoReset = true;
}
var coinmarketCapApiClient = new RestClient(_tickerSettings.ApiUrl); var coinmarketCapApiClient = new RestClient(_tickerSettings.ApiUrl);
var coinmarketCapApiRequest = new RestRequest(Method.GET); var coinmarketCapApiRequest = new RestRequest(Method.GET);
var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest); var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest);
...@@ -48,6 +53,7 @@ namespace Stratis.Guru.Services ...@@ -48,6 +53,7 @@ namespace Stratis.Guru.Services
var blockchainStatsRequest = new RestRequest(Method.GET); var blockchainStatsRequest = new RestRequest(Method.GET);
_memoryCache.Set("BlockchainStats", blockchainStatsClient.Execute(blockchainStatsRequest).Content); _memoryCache.Set("BlockchainStats", blockchainStatsClient.Execute(blockchainStatsRequest).Content);
}; };
_updateTimer.Start(); _updateTimer.Start();
return Task.CompletedTask; return Task.CompletedTask;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment