1
0
ntminer 5 жил өмнө
parent
commit
8a3af76192

+ 80 - 0
src/NTMinerDataSchemas/Core/MinerServer/ClientData.cs

@@ -327,6 +327,86 @@ namespace NTMiner.Core.MinerServer {
             this.AESPasswordOn = minerSign.AESPasswordOn;
         }
 
+        public SpeedData ToSpeedData() {
+            return new SpeedData {
+                AutoRestartKernelTimes = this.AutoRestartKernelTimes,
+                AutoStartDelaySeconds = this.AutoStartDelaySeconds,
+                BootOn = this.BootOn,
+                ClientId = this.ClientId,
+                CpuGETemperatureSeconds = this.CpuGETemperatureSeconds,
+                CpuLETemperatureSeconds = this.CpuLETemperatureSeconds,
+                CpuPerformance = this.CpuPerformance,
+                CpuStartTemperature = this.CpuStartTemperature,
+                CpuStopTemperature = this.CpuStopTemperature,
+                CpuTemperature = this.CpuTemperature,
+                DiskSpace = this.DiskSpace,
+                DualCoinCode = this.DualCoinCode,
+                DualCoinPool = this.DualCoinPool,
+                DualCoinPoolDelay = this.DualCoinPoolDelay,
+                DualCoinRejectShare = this.DualCoinRejectShare,
+                DualCoinSpeed = this.DualCoinSpeed,
+                DualCoinSpeedOn = this.DualCoinSpeedOn,
+                DualCoinTotalShare = this.DualCoinTotalShare,
+                DualCoinWallet = this.DualCoinWallet,
+                GpuDriver = this.GpuDriver,
+                GpuInfo = this.GpuInfo,
+                GpuTable = this.GpuTable,
+                GpuType = this.GpuType,
+                HighCpuPercent = this.HighCpuPercent,
+                HighCpuSeconds = this.HighCpuSeconds,
+                IsAutoBoot = this.IsAutoBoot,
+                IsAutoDisableWindowsFirewall = this.IsAutoDisableWindowsFirewall,
+                IsAutoRestartKernel = this.IsAutoRestartKernel,
+                IsAutoStart = this.IsAutoStart,
+                IsAutoStartByCpu = this.IsAutoStartByCpu,
+                IsAutoStopByCpu = this.IsAutoStopByCpu,
+                IsDisableAntiSpyware = this.IsDisableAntiSpyware,
+                IsDisableUAC = this.IsDisableUAC,
+                IsDisableWAU = this.IsDisableWAU,
+                IsDualCoinEnabled = this.IsDualCoinEnabled,
+                IsFoundOneGpuShare = this.IsFoundOneGpuShare,
+                IsGotOneIncorrectGpuShare = this.IsGotOneIncorrectGpuShare,
+                IsMining = this.IsMining,
+                IsNoShareRestartComputer = this.IsNoShareRestartComputer,
+                IsNoShareRestartKernel = this.IsNoShareRestartKernel,
+                IsOuterUserEnabled = this.IsOuterUserEnabled,
+                IsPeriodicRestartComputer = this.IsPeriodicRestartComputer,
+                IsPeriodicRestartKernel = this.IsPeriodicRestartKernel,
+                IsRaiseHighCpuEvent = this.IsRaiseHighCpuEvent,
+                IsRejectOneGpuShare = this.IsRejectOneGpuShare,
+                Kernel = this.Kernel,
+                KernelCommandLine = this.KernelCommandLine,
+                KernelSelfRestartCount = this.KernelSelfRestartCount,
+                LocalIp = this.LocalIp,
+                LocalServerMessageTimestamp = this.LocalServerMessageTimestamp,
+                MACAddress = this.MACAddress,
+                MainCoinCode = this.MainCoinCode,
+                MainCoinPool = this.MainCoinPool,
+                MainCoinPoolDelay = this.MainCoinPoolDelay,
+                MainCoinRejectShare = this.MainCoinRejectShare,
+                MainCoinSpeed = this.MainCoinSpeed,
+                MainCoinSpeedOn = this.MainCoinSpeedOn,
+                MainCoinTotalShare = this.MainCoinTotalShare,
+                MainCoinWallet = this.MainCoinWallet,
+                MineContextId = this.MineContextId,
+                MinerIp = this.MinerIp,
+                MinerName = this.MinerName,
+                MineStartedOn = this.MineStartedOn,
+                MineWorkId = this.MineWorkId,
+                MineWorkName = this.MineWorkName,
+                NoShareRestartComputerMinutes = this.NoShareRestartComputerMinutes,
+                NoShareRestartKernelMinutes = this.NoShareRestartKernelMinutes,
+                OSName = this.OSName,
+                OSVirtualMemoryMb = this.OSVirtualMemoryMb,
+                PeriodicRestartComputerHours = this.PeriodicRestartComputerHours,
+                PeriodicRestartComputerMinutes = this.PeriodicRestartComputerMinutes,
+                PeriodicRestartKernelHours = this.PeriodicRestartKernelHours,
+                PeriodicRestartKernelMinutes = this.PeriodicRestartKernelMinutes,
+                TotalPhysicalMemoryMb = this.TotalPhysicalMemoryMb,
+                Version = this.Version
+            };
+        }
+
         /// <summary>
         /// 上报算力时。
         /// 因为只有MinerData具有的成员发生了变化时才需要持久化所以该非法输出isMinerDataChanged参数以表示MinerData的成员是否发生了变化。

+ 15 - 2
src/NTMinerDataSchemas/Report/SpeedData.cs

@@ -8,6 +8,9 @@ namespace NTMiner.Report {
     /// TODO:考虑加个压缩逻辑,只上报变更的字段
     /// </summary>
     public class SpeedData : ISpeedData {
+        private string _dualCoinCode;
+        private int _totalPhysicalMemoryMb;
+
         public SpeedData() {
             GpuTable = new GpuSpeedData[0];
         }
@@ -42,7 +45,18 @@ namespace NTMiner.Report {
         public string OSName { get; set; }
         // ReSharper disable once InconsistentNaming
         public int OSVirtualMemoryMb { get; set; }
-        public int TotalPhysicalMemoryMb { get; set; }
+        public int TotalPhysicalMemoryMb {
+            get {
+                // 因为有客户端版本的单位不正确传上来的是kb不是Mb所以如果值较大除以1024
+                if (_totalPhysicalMemoryMb >= 100 * 1024) {
+                    _totalPhysicalMemoryMb /= 1024;
+                }
+                return _totalPhysicalMemoryMb;
+            }
+            set {
+                _totalPhysicalMemoryMb = value;
+            }
+        }
         public string DiskSpace { get; set; }
 
         public Guid ClientId { get; set; }
@@ -82,7 +96,6 @@ namespace NTMiner.Report {
 
         public string Kernel { get; set; }
 
-        private string _dualCoinCode;
         public string DualCoinCode {
             get => _dualCoinCode ?? string.Empty;
             set => _dualCoinCode = value;

+ 14 - 3
src/WebApiServer/Core/Impl/ClientDataSet.cs

@@ -112,9 +112,12 @@ namespace NTMiner.Core.Impl {
             if (speedData == null || speedData.ClientId == Guid.Empty) {
                 return;
             }
-            // 因为有客户端版本的单位不正确传上来的是kb不是Mb所以如果值较大除以1024
-            if (speedData.TotalPhysicalMemoryMb >= 100 * 1024) {
-                speedData.TotalPhysicalMemoryMb /= 1024;
+            if (string.IsNullOrEmpty(minerIp)) {
+                return;
+            }
+            bool isFromWsServerNode = minerIp.Contains(':');
+            if (!isFromWsServerNode) {
+                _speedDataRedis.SetAsync(speedData);
             }
             ClientData clientData = GetByClientId(speedData.ClientId);
             if (clientData == null) {
@@ -136,6 +139,9 @@ namespace NTMiner.Core.Impl {
             if (state == null || state.ClientId == Guid.Empty) {
                 return;
             }
+            if (string.IsNullOrEmpty(minerIp)) {
+                return;
+            }
             ClientData clientData = GetByClientId(state.ClientId);
             if (clientData == null) {
                 clientData = ClientData.Create(state, minerIp);
@@ -147,6 +153,11 @@ namespace NTMiner.Core.Impl {
                     DoUpdateSave(MinerData.Create(clientData));
                 }
             }
+            bool isFromWsServerNode = minerIp.Contains(':');
+            if (!isFromWsServerNode) {
+                var speedData = clientData.ToSpeedData();
+                _speedDataRedis.SetAsync(speedData);
+            }
         }
 
         private void Add(ClientData clientData) {