ntminer 5 years ago
parent
commit
801a9841a7

+ 1 - 0
src/NTMinerRpcClient/NTMinerRpcClient.csproj

@@ -74,6 +74,7 @@
     <Compile Include="Services\Official\ClientDataBinaryService.cs" />
     <Compile Include="Services\Official\CoinSnapshotService.cs" />
     <Compile Include="Services\Official\FileUrlService.cs" />
+    <Compile Include="Services\Official\GpuNameService.cs" />
     <Compile Include="Services\Official\NTMinerWalletService.cs" />
     <Compile Include="Services\OfficialServices.cs" />
     <Compile Include="Services\Official\OverClockDataService.cs" />

+ 28 - 0
src/NTMinerRpcClient/Services/Official/GpuNameService.cs

@@ -0,0 +1,28 @@
+using NTMiner.Controllers;
+using NTMiner.Core.Gpus;
+using System;
+using System.Collections.Generic;
+
+namespace NTMiner.Services.Official {
+    public class GpuNameService {
+        private readonly string _controllerName = RpcRoot.GetControllerName<IGpuNameController>();
+
+        public GpuNameService() { }
+
+        public void GetGpuNamesAsync(Action<DataResponse<List<GpuName>>, Exception> callback) {
+            JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.GpuNames), new object(), callback, timeountMilliseconds: 5 * 1000);
+        }
+
+        public void GetGpuNameCountsAsync(Action<DataResponse<List<GpuNameCount>>, Exception> callback) {
+            JsonRpcRoot.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.GpuNameCounts), new object(), callback, timeountMilliseconds: 5 * 1000);
+        }
+
+        public void SetGpuNameAsync(GpuName gpuName, Action<ResponseBase, Exception> callback) {
+            JsonRpcRoot.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.SetGpuName), gpuName, callback, timeountMilliseconds: 5 * 1000);
+        }
+
+        public void RemoveGpuNameAsync(GpuName gpuName, Action<ResponseBase, Exception> callback) {
+            JsonRpcRoot.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.RemoveGpuName), gpuName, callback, timeountMilliseconds: 5 * 1000);
+        }
+    }
+}

+ 3 - 0
src/WebApiServer/Controllers/GpuNameController.cs

@@ -14,6 +14,7 @@ namespace NTMiner.Controllers {
             return DataResponse<List<GpuName>>.Ok(WebApiRoot.GpuNameSet.AsEnumerable().ToList());
         }
 
+        [Role.Admin]
         [HttpGet]
         [HttpPost]
         public DataResponse<List<GpuNameCount>> GpuNameCounts(object request) {
@@ -23,6 +24,7 @@ namespace NTMiner.Controllers {
             return DataResponse<List<GpuNameCount>>.Ok(WebApiRoot.GpuNameSet.GetGpuNameCounts().ToList());
         }
 
+        [Role.Admin]
         [HttpPost]
         public ResponseBase SetGpuName(DataRequest<GpuName> request) {
             if (request == null || request.Data == null) {
@@ -32,6 +34,7 @@ namespace NTMiner.Controllers {
             return ResponseBase.Ok("设置成功");
         }
 
+        [Role.Admin]
         [HttpPost]
         public ResponseBase RemoveGpuName(DataRequest<GpuName> request) {
             if (request == null || request.Data == null) {