Kaynağa Gözat

Minor improvements

PascalCoin 1 yıl önce
ebeveyn
işleme
0015024f8d
2 değiştirilmiş dosya ile 9 ekleme ve 10 silme
  1. 0 10
      src/core/UBlockChain.pas
  2. 9 0
      src/core/UPCAbstractMem.pas

+ 0 - 10
src/core/UBlockChain.pas

@@ -1097,7 +1097,6 @@ var fs: TFileStream;
     LBankfilename,Laux_newfilename: AnsiString;
     ms : TMemoryStream;
   LTC : TTickCount;
-  LOldB : Boolean;
 begin
   Result := true;
   LBankfilename := GetSafeboxCheckpointingFileName(GetStorageFolder(Orphan),BlocksCount);
@@ -1142,16 +1141,7 @@ begin
         end;
       end;
     end;
-    // Flush pending
-    if (FStorage is TAbstractMemBlockchainStorage) then begin
-      LOldB := TAbstractMemBlockchainStorage(FStorage).UseMultithread;
-      TAbstractMemBlockchainStorage(FStorage).UseMultithread := False;
-      TAbstractMemBlockchainStorage(FStorage).UseMultithread := LOldB;
-
-    end;
   end;
-
-
 end;
 
 procedure TPCBank.UpdateValuesFromSafebox;

+ 9 - 0
src/core/UPCAbstractMem.pas

@@ -613,6 +613,7 @@ begin
   end;
   Inc(FStats.FlushesCount);
   Inc(Fstats.FlushesMillis, TPlatform.GetElapsedMilliseconds(Ltc) );
+  TLog.NewLog(ltdebug,Self.ClassName,Format('AbstractMem Safebox flushed in %.2f seconds',[TPlatform.GetElapsedMilliseconds(Ltc)/1000]));
 end;
 
 Procedure DoCopyFile(const ASource, ADest : String);
@@ -795,6 +796,7 @@ end;
 
 procedure TPCAbstractMem.UpdateSafeboxFileName(const ANewSafeboxFileName: String);
 var LReadOnly, Ltmp : Boolean;
+  LCacheMem : TCacheMem;
 begin
   if SameFileName(FFileName,ANewSafeboxFileName) then Exit;
 
@@ -812,6 +814,13 @@ begin
   end;
   if FAbstractMem is TFileMem then begin
     TFileMem(FAbstractMem).SetCachePerformance(True,1024,FMaxMemUsage,200000);
+    LCacheMem := TFileMem(FAbstractMem).LockCache;
+    Try
+      LCacheMem.OnFlushedCache := OnCacheMemFlushedCache;
+      LCacheMem.OnLog := OnCacheMemLog;
+    Finally
+      TFileMem(FAbstractMem).UnlockCache;
+    End;
   end;
   DoInit(Ltmp);
 end;