Browse Source

Do not save safebox when moving

Do not save safebox nor check memory when moving orphan blocks
PascalCoin 7 years ago
parent
commit
e5c6ea34b9
2 changed files with 5 additions and 0 deletions
  1. 3 0
      src/core/UBlockChain.pas
  2. 2 0
      src/core/UFileStorage.pas

+ 3 - 0
src/core/UBlockChain.pas

@@ -389,6 +389,7 @@ Type
     FReadOnly: Boolean;
     procedure SetBank(const Value: TPCBank);
   protected
+    FIsMovingBlockchain : Boolean;
     procedure SetOrphan(const Value: TOrphan); virtual;
     procedure SetReadOnly(const Value: Boolean); virtual;
     Function DoLoadBlockChain(Operations : TPCOperationsComp; Block : Cardinal) : Boolean; virtual; abstract;
@@ -2150,6 +2151,7 @@ begin
   inherited;
   FOrphan := '';
   FReadOnly := false;
+  FIsMovingBlockchain := False;
 end;
 
 procedure TStorage.DeleteBlockChainBlocks(StartingDeleteBlock: Cardinal);
@@ -2206,6 +2208,7 @@ end;
 function TStorage.SaveBank: Boolean;
 begin
   Result := true;
+  If FIsMovingBlockchain then Exit;
   if Not TPCSafeBox.MustSafeBoxBeSaved(Bank.BlocksCount) then exit; // No save
   Try
     Result := DoSaveBank;

+ 2 - 0
src/core/UFileStorage.pas

@@ -403,6 +403,7 @@ begin
       end;
       if db is TFileStorage then TFileStorage(db).LockBlockChainStream;
       try
+        db.FIsMovingBlockchain:=True;
         ops := TPCOperationsComp.Create(Nil);
         try
           b := Start_Block;
@@ -420,6 +421,7 @@ begin
           DoCopySafebox;
         end;
       finally
+        db.FIsMovingBlockchain:=False;
         if db is TFileStorage then TFileStorage(db).UnlockBlockChainStream;
       end;
     Finally