diff --git a/src/core/UBlockChain.pas b/src/core/UBlockChain.pas index 2ac3b37f..65da5bd7 100644 --- a/src/core/UBlockChain.pas +++ b/src/core/UBlockChain.pas @@ -1097,7 +1097,6 @@ function TPCBank.DoSaveBank: Boolean; LBankfilename,Laux_newfilename: AnsiString; ms : TMemoryStream; LTC : TTickCount; - LOldB : Boolean; begin Result := true; LBankfilename := GetSafeboxCheckpointingFileName(GetStorageFolder(Orphan),BlocksCount); @@ -1142,16 +1141,7 @@ function TPCBank.DoSaveBank: Boolean; 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; diff --git a/src/core/UPCAbstractMem.pas b/src/core/UPCAbstractMem.pas index abbfc2b1..54767539 100644 --- a/src/core/UPCAbstractMem.pas +++ b/src/core/UPCAbstractMem.pas @@ -613,6 +613,7 @@ procedure TPCAbstractMem.FlushCache; 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 @@ procedure TPCAbstractMem.SetUseCacheOnAbstractMemLists(const Value: Boolean); procedure TPCAbstractMem.UpdateSafeboxFileName(const ANewSafeboxFileName: String); var LReadOnly, Ltmp : Boolean; + LCacheMem : TCacheMem; begin if SameFileName(FFileName,ANewSafeboxFileName) then Exit; @@ -812,6 +814,13 @@ procedure TPCAbstractMem.UpdateSafeboxFileName(const ANewSafeboxFileName: String 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;