Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
guru
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
guru
Commits
052284f2
Commit
052284f2
authored
Oct 20, 2018
by
Clint Mourlevat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing TickerService -> UpdzteInfosService and adding stats from the NakoAPI
parent
cb794784
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
BlockExplorerController.cs
Controllers/BlockExplorerController.cs
+2
-2
UpdateInfosService.cs
Services/UpdateInfosService.cs
+10
-2
Startup.cs
Startup.cs
+1
-1
No files found.
Controllers/BlockExplorerController.cs
View file @
052284f2
...
...
@@ -47,7 +47,7 @@ namespace Stratis.Guru.Controllers
[
Route
(
"address/{address}"
)]
public
IActionResult
Address
(
string
address
)
{
var
endpointClient
=
new
RestClient
(
$"
{
_nakoApiSettings
.
Endpoint
}
address/
{
address
}
/transactions"
);
var
endpointClient
=
new
RestClient
(
$"
{
_nakoApiSettings
.
Endpoint
}
query/
address/
{
address
}
/transactions"
);
var
enpointRequest
=
new
RestRequest
(
Method
.
GET
);
var
endpointResponse
=
endpointClient
.
Execute
(
enpointRequest
);
return
View
(
JsonConvert
.
DeserializeObject
(
endpointResponse
.
Content
));
...
...
@@ -56,7 +56,7 @@ namespace Stratis.Guru.Controllers
[
Route
(
"transaction/{transactionId}"
)]
public
IActionResult
Transaction
(
string
transactionId
)
{
var
endpointClient
=
new
RestClient
(
$"
{
_nakoApiSettings
.
Endpoint
}
transaction/
{
transactionId
}
"
);
var
endpointClient
=
new
RestClient
(
$"
{
_nakoApiSettings
.
Endpoint
}
query/
transaction/
{
transactionId
}
"
);
var
enpointRequest
=
new
RestRequest
(
Method
.
GET
);
var
endpointResponse
=
endpointClient
.
Execute
(
enpointRequest
);
return
View
(
JsonConvert
.
DeserializeObject
(
endpointResponse
.
Content
));
...
...
Services/
Ticker
Service.cs
→
Services/
UpdateInfos
Service.cs
View file @
052284f2
...
...
@@ -4,24 +4,28 @@ using System.Threading.Tasks;
using
Microsoft.AspNetCore.SignalR
;
using
Microsoft.Extensions.Caching.Memory
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Options
;
using
RestSharp
;
using
Stratis.Guru.Hubs
;
using
Stratis.Guru.Settings
;
namespace
Stratis.Guru.Services
{
public
class
Ticker
Service
:
IHostedService
,
IDisposable
public
class
UpdateInfos
Service
:
IHostedService
,
IDisposable
{
private
readonly
IMemoryCache
_memoryCache
;
private
readonly
IHubContext
<
UpdateHub
>
_hubContext
;
private
readonly
UpdateHub
_hub
;
private
readonly
System
.
Timers
.
Timer
updateTimer
;
private
readonly
NakoApiSettings
_nakoApiSettings
;
public
TickerService
(
IMemoryCache
memoryCache
,
UpdateHub
hub
,
IHubContext
<
UpdateHub
>
hubContext
)
public
UpdateInfosService
(
IMemoryCache
memoryCache
,
UpdateHub
hub
,
IHubContext
<
UpdateHub
>
hubContext
,
IOptions
<
NakoApiSettings
>
nakoApiSettings
)
{
_memoryCache
=
memoryCache
;
_hub
=
hub
;
_hubContext
=
hubContext
;
updateTimer
=
new
System
.
Timers
.
Timer
();
_nakoApiSettings
=
nakoApiSettings
.
Value
;
}
public
Task
StartAsync
(
CancellationToken
cancellationToken
)
...
...
@@ -37,6 +41,10 @@ namespace Stratis.Guru.Services
_memoryCache
.
Set
(
"Coinmarketcap"
,
coinmarketcapApi
.
Content
);
Console
.
WriteLine
(
DateTime
.
Now
+
" - Ticker Updated"
);
await
_hubContext
.
Clients
.
All
.
SendAsync
(
"UpdateTicker"
,
cancellationToken
);
var
blockchainStatsClient
=
new
RestClient
(
$"
{
_nakoApiSettings
.
Endpoint
}
stats"
);
var
blockchainStatsRequest
=
new
RestRequest
(
Method
.
GET
);
_memoryCache
.
Set
(
"BlockchainStats"
,
blockchainStatsClient
.
Execute
(
blockchainStatsRequest
).
Content
);
};
updateTimer
.
Start
();
return
Task
.
CompletedTask
;
...
...
Startup.cs
View file @
052284f2
...
...
@@ -45,7 +45,7 @@ namespace Stratis.Guru
services
.
AddMemoryCache
();
services
.
AddHostedService
<
Ticker
Service
>();
services
.
AddHostedService
<
UpdateInfos
Service
>();
//services.AddHostedService<VanityService>();
services
.
AddTransient
<
UpdateHub
>();
services
.
AddSingleton
<
IAsk
,
Ask
>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment