Browse Source

Fixed downloading new safebox bug

PascalCoin 5 years ago
parent
commit
4319b0edaa
2 changed files with 4 additions and 3 deletions
  1. 1 1
      src/core/UAccounts.pas
  2. 3 2
      src/core/UBlockChain.pas

+ 1 - 1
src/core/UAccounts.pas

@@ -3903,7 +3903,7 @@ begin
   isChangeTargetBlock := False;
   isChangeTargetBlock := False;
   if (newOperationBlock.block > 0) then begin
   if (newOperationBlock.block > 0) then begin
     // protocol
     // protocol
-    if (newOperationBlock.protocol_version<>CurrentProtocol) then begin
+    if (newOperationBlock.protocol_version<>lastBlock.protocol_version) then begin
       // Protocol must be 1 or 2. If 1 then all prior blocksmust be 1 and never 2 (invalide blockchain version scenario v1...v2...v1)
       // Protocol must be 1 or 2. If 1 then all prior blocksmust be 1 and never 2 (invalide blockchain version scenario v1...v2...v1)
       If (lastBlock.protocol_version>newOperationBlock.protocol_version) then begin
       If (lastBlock.protocol_version>newOperationBlock.protocol_version) then begin
         errors := 'Invalid PascalCoin protocol version: '+IntToStr( newOperationBlock.protocol_version )+' Current: '+IntToStr(CurrentProtocol)+' Previous:'+IntToStr(lastBlock.protocol_version);
         errors := 'Invalid PascalCoin protocol version: '+IntToStr( newOperationBlock.protocol_version )+' Current: '+IntToStr(CurrentProtocol)+' Previous:'+IntToStr(lastBlock.protocol_version);

+ 3 - 2
src/core/UBlockChain.pas

@@ -925,7 +925,7 @@ Var
   errors: String;
   errors: String;
   newBlock: TBlockAccount;
   newBlock: TBlockAccount;
   n : Int64;
   n : Int64;
-  tc : TTickCount;
+  tc, LStartProcessTC : TTickCount;
   LBlocks : TList<TPCOperationsComp>;
   LBlocks : TList<TPCOperationsComp>;
   LTmpPCOperationsComp : TPCOperationsComp;
   LTmpPCOperationsComp : TPCOperationsComp;
   i,j, LProgressBlock, LProgressEndBlock, LOpsInBlocks : Integer;
   i,j, LProgressBlock, LProgressEndBlock, LOpsInBlocks : Integer;
@@ -936,6 +936,7 @@ begin
     raise Exception.Create('Is restoring!');
     raise Exception.Create('Is restoring!');
   end;
   end;
   tc := TPlatform.GetTickCount;
   tc := TPlatform.GetTickCount;
+  LStartProcessTC := tc;
   TPCThread.ProtectEnterCriticalSection(Self,FBankLock);
   TPCThread.ProtectEnterCriticalSection(Self,FBankLock);
   try
   try
     FUpgradingToV2 := NOT Storage.HasUpgradedToVersion2;
     FUpgradingToV2 := NOT Storage.HasUpgradedToVersion2;
@@ -1026,7 +1027,7 @@ begin
       finally
       finally
         LBlocks.Free;
         LBlocks.Free;
         if FUpgradingToV2 then Storage.CleanupVersion1Data;
         if FUpgradingToV2 then Storage.CleanupVersion1Data;
-        NewLog(Nil, ltinfo,'End restoring from disk operations (Max '+inttostr(max_block)+') Orphan: ' + Storage.Orphan+' Restored '+Inttostr(BlocksCount)+' blocks');
+        NewLog(Nil, ltinfo,'End restoring from disk operations (Max '+inttostr(max_block)+') Orphan: ' + Storage.Orphan+' Restored '+Inttostr(BlocksCount)+' blocks in '+IntToStr(TPlatform.GetElapsedMilliseconds(LStartProcessTC))+' milliseconds');
       end;
       end;
 
 
     finally
     finally