Browse Source

Improvement for multicpu randomhash

PascalCoin 6 years ago
parent
commit
6085703628
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/core/UPoolMinerThreads.pas

+ 9 - 1
src/core/UPoolMinerThreads.pas

@@ -160,6 +160,7 @@ Type
     FChangeTimestampAndNOnceBytePos : Integer;
     FChangeTimestampAndNOnceBytePos : Integer;
     FDigestStreamMsg : TMemoryStream;
     FDigestStreamMsg : TMemoryStream;
     FMinNOnce,FMaxNOnce : Cardinal;
     FMinNOnce,FMaxNOnce : Cardinal;
+    FResetNOnce : Boolean;						  
     procedure BCExecute; override;
     procedure BCExecute; override;
   public
   public
     Constructor Create(CPUDeviceThread : TCPUDeviceThread);
     Constructor Create(CPUDeviceThread : TCPUDeviceThread);
@@ -723,6 +724,7 @@ begin
         cpu.FDigestStreamMsg.size := 0;
         cpu.FDigestStreamMsg.size := 0;
         cpu.FChangeTimestampAndNOnceBytePos:=npos;
         cpu.FChangeTimestampAndNOnceBytePos:=npos;
         cpu.FMinNOnce:=nextmin;
         cpu.FMinNOnce:=nextmin;
+        cpu.FResetNOnce:=True;
         if (FCPUs>0) then cpu.FMaxNOnce:=nextmin + (Cardinal($FFFFFFFF) DIV FCPUs) - 1
         if (FCPUs>0) then cpu.FMaxNOnce:=nextmin + (Cardinal($FFFFFFFF) DIV FCPUs) - 1
         else cpu.FMaxNOnce:= nextmin + (Cardinal($FFFFFFFF)) - 1;
         else cpu.FMaxNOnce:= nextmin + (Cardinal($FFFFFFFF)) - 1;
         nextmin := cpu.FMaxNOnce+1;
         nextmin := cpu.FMaxNOnce+1;
@@ -787,7 +789,12 @@ begin
             roundsToDo := 10000;
             roundsToDo := 10000;
           end;
           end;
           baseRealTC := TPlatform.GetTickCount;
           baseRealTC := TPlatform.GetTickCount;
-          If (nonce<FMinNOnce) Or (nonce>FMaxNOnce) then nonce:=FMinNOnce;
+          If (FResetNOnce) then begin
+            FResetNOnce := False;
+            If (nonce<FMinNOnce) Or (nonce>FMaxNOnce) then begin
+              nonce:=FMinNOnce;
+            end;
+          end;
           // Timestamp
           // Timestamp
           ts := UnivDateTimeToUnix(DateTime2UnivDateTime(now));
           ts := UnivDateTimeToUnix(DateTime2UnivDateTime(now));
           if ts<=FCurrentMinerValuesForWork.timestamp then ts := FCurrentMinerValuesForWork.timestamp+1;
           if ts<=FCurrentMinerValuesForWork.timestamp then ts := FCurrentMinerValuesForWork.timestamp+1;
@@ -869,6 +876,7 @@ begin
   FLock := TCriticalSection.Create;
   FLock := TCriticalSection.Create;
   FDigestStreamMsg := TMemoryStream.Create;
   FDigestStreamMsg := TMemoryStream.Create;
   FMinNOnce := 0; FMaxNOnce:=$FFFFFFFF;
   FMinNOnce := 0; FMaxNOnce:=$FFFFFFFF;
+  FResetNOnce:=True;
   inherited Create(false);
   inherited Create(false);
 end;
 end;