Browse Source

Optimize bootstrap

PascalCoinDev 2 years ago
parent
commit
62b15b2554
2 changed files with 6 additions and 4 deletions
  1. 3 3
      src/core/UNetProtocol.pas
  2. 3 1
      src/core/UPCAbstractMem.pas

+ 3 - 3
src/core/UNetProtocol.pas

@@ -1921,11 +1921,11 @@ Const CT_LogSender = 'GetNewBlockChainFromClient';
       Exit;
     end;
       // Will obtain chunks of 10000 blocks each -> Note: Maximum is CT_MAX_SAFEBOXCHUNK_BLOCKS
-      for i:=0 to ((LDownloadedSafeboxBlocksCount-1) DIV 10000) do begin // Bug v3.0.1 and minors
+      for i:=0 to ((LDownloadedSafeboxBlocksCount-1) DIV CT_MAX_SAFEBOXCHUNK_BLOCKS) do begin // Bug v3.0.1 and minors
         FNewBlockChainFromClientStatus := Format('Receiving new safebox with %d blocks (step %d/%d) from %s',
-          [LDownloadedSafeboxBlocksCount,i+1,((LDownloadedSafeboxBlocksCount-1) DIV 10000)+1,Connection.ClientRemoteAddr]);
+          [LDownloadedSafeboxBlocksCount,i+1,((LDownloadedSafeboxBlocksCount-1) DIV CT_MAX_SAFEBOXCHUNK_BLOCKS)+1,Connection.ClientRemoteAddr]);
         LreceivedChunk := TPCTemporalFileStream.Create(Format('CHUNK_%.3d_',[i]));
-        if (Not DownloadSafeBoxChunk(LDownloadedSafeboxBlocksCount,ASafeboxLastOperationBlock.initial_safe_box_hash,(i*10000),((i+1)*10000)-1,LreceivedChunk,safeBoxHeader,errors)) then begin
+        if (Not DownloadSafeBoxChunk(LDownloadedSafeboxBlocksCount,ASafeboxLastOperationBlock.initial_safe_box_hash,(i*CT_MAX_SAFEBOXCHUNK_BLOCKS),((i+1)*CT_MAX_SAFEBOXCHUNK_BLOCKS)-1,LreceivedChunk,safeBoxHeader,errors)) then begin
           LreceivedChunk.Free;
           TLog.NewLog(ltError,CT_LogSender,errors);
           Exit;

+ 3 - 1
src/core/UPCAbstractMem.pas

@@ -515,8 +515,10 @@ begin
   end else begin
     FAbstractMem := TMem.Create(0,AReadOnly);
   end;
+
   if FAbstractMem is TFileMem then begin
-    TFileMem(FAbstractMem).SetCachePerformance(True,1024,FMaxMemUsage,200000);
+    TFileMem(FAbstractMem).IncreaseFileBytes := 10 * 1024*1024; // 10Mb each increase
+    TFileMem(FAbstractMem).SetCachePerformance(True,1024,FMaxMemUsage,400000);
     LCacheMem := TFileMem(FAbstractMem).LockCache;
     Try
       LCacheMem.OnFlushedCache := OnCacheMemFlushedCache;