瀏覽代碼

Miner minor improvements

PascalCoin 5 年之前
父節點
當前提交
7828976b50
共有 2 個文件被更改,包括 18 次插入16 次删除
  1. 5 4
      src/core/UPoolMinerThreads.pas
  2. 13 12
      src/pascalcoin_miner.pp

+ 5 - 4
src/core/UPoolMinerThreads.pas

@@ -47,7 +47,7 @@ Type
 
   TCustomMinerDeviceThreadClass = Class of TCustomMinerDeviceThread;
 
-  TOnFoundNonce = Procedure(Sender : TCustomMinerDeviceThread; Timestamp, nOnce : Cardinal) of object;
+  TOnFoundNonce = Procedure(Sender : TCustomMinerDeviceThread; const AUsedMinerValuesForWork : TMinerValuesForWork; ATimestamp, AnOnce : Cardinal; const APoW : TRawBytes) of object;
 
   { TPoolMinerThread }
 
@@ -531,7 +531,7 @@ begin
   if (TBaseType.BinStrComp(LHash,usedMinerValuesForWork.target_pow)<=0) then begin
     inc(FGlobaDeviceStats.WinsCount);
     FPoolMinerThread.OnMinerNewBlockFound(self,usedMinerValuesForWork,Timestamp,nOnce,LHash);
-    If Assigned(FOnFoundNOnce) then FOnFoundNOnce(Self,Timestamp,nOnce);
+    If Assigned(FOnFoundNOnce) then FOnFoundNOnce(Self,usedMinerValuesForWork,Timestamp,nOnce,LHash);
   end else begin
     inc(FGlobaDeviceStats.Invalids);
     if LUseRandomHash then
@@ -681,7 +681,7 @@ end;
 procedure TCPUDeviceThread.BCExecute;
 begin
   while not terminated do begin
-    sleep(1);
+    sleep(10);
   end;
   FCPUs:=0;
   CheckCPUs;
@@ -863,7 +863,7 @@ begin
             if FCurrentMinerValuesForWork.version < CT_PROTOCOL_5 then
               roundsToDo := 20
             else
-              roundsToDo := 200;
+              roundsToDo := 200+Random(200);
           end else begin
             roundsToDo := 10000;
           end;
@@ -1012,6 +1012,7 @@ begin
   FResetNOnce:=True;
   FJobNum := 0;
   inherited Create(false);
+  Priority := tpHigher;
 end;
 
 destructor TCPUOpenSSLMinerThread.Destroy;

+ 13 - 12
src/pascalcoin_miner.pp

@@ -40,7 +40,7 @@ type
     procedure OnConnectionStateChanged(Sender : TObject);
     procedure OnDeviceStateChanged(Sender : TObject);
     procedure OnMinerValuesChanged(Sender : TObject);
-    procedure OnFoundNOnce(Sender : TCustomMinerDeviceThread; Timestamp, nOnce : Cardinal);
+    procedure OnFoundNOnce(Sender : TCustomMinerDeviceThread; const AUsedMinerValuesForWork : TMinerValuesForWork; ATimestamp, AnOnce : Cardinal; const APoW : TRawBytes);
     procedure WriteLine(nline : Integer; txt : String);
     procedure OnInThreadNewLog(logtype : TLogType; Time : TDateTime; ThreadID : TThreadID; Const sender, logtext : AnsiString);
   protected
@@ -142,10 +142,10 @@ begin
   end;
 end;
 
-procedure TPascalMinerApp.OnFoundNOnce(Sender: TCustomMinerDeviceThread; Timestamp, nOnce: Cardinal);
+procedure TPascalMinerApp.OnFoundNOnce(Sender : TCustomMinerDeviceThread; const AUsedMinerValuesForWork : TMinerValuesForWork; ATimestamp, AnOnce : Cardinal; const APoW : TRawBytes);
 begin
-  WriteLine(CT_Line_LastFound + FDeviceThreads.Count,FormatDateTime('hh:nn:ss',now)+' Block:'+IntToStr(Sender.MinerValuesForWork.block)+' NOnce:'+Inttostr(nOnce)+
-    ' Timestamp:'+inttostr(Timestamp)+' Miner:'+Sender.MinerValuesForWork.payload_start.ToPrintable);
+  WriteLine(CT_Line_LastFound + FDeviceThreads.Count,FormatDateTime('hh:nn:ss',now)+' Block:'+IntToStr(Sender.MinerValuesForWork.block)+' NOnce:'+Inttostr(AnOnce)+
+    ' Timestamp:'+inttostr(ATimestamp)+' Miner:'+Sender.MinerValuesForWork.payload_start.ToPrintable);
 end;
 
 procedure TPascalMinerApp.WriteLine(nline: Integer; txt: String);
@@ -238,6 +238,15 @@ var
         Terminate;
         exit;
       end;
+
+      If Not FileExists(ExtractFileDir(ExeName)+PathDelim+CT_OpenCL_FileName) then begin
+        Writeln('**********************');
+        Writeln('OpenCL file not found!');
+        Writeln('File: ',CT_OpenCL_FileName);
+        Terminate;
+        Exit;
+      end;
+
       strl := TStringList.Create;
       try
         if (d<0) then begin
@@ -438,14 +447,6 @@ begin
       Exit;
     end;
 
-    If Not FileExists(ExtractFileDir(ExeName)+PathDelim+CT_OpenCL_FileName) then begin
-      Writeln('**********************');
-      Writeln('OpenCL file not found!');
-      Writeln('File: ',CT_OpenCL_FileName);
-      Exit;
-    end;
-
-
     If HasOption('s','server') then begin
       s := Trim(GetOptionValue('s','server'));
       if (s='') then s := 'localhost:'+inttostr(CT_JSONRPCMinerServer_Port);