Browse Source

Update based on current protocol

PascalCoin 2 years ago
parent
commit
02e64ce9a5
2 changed files with 13 additions and 4 deletions
  1. 9 2
      src/core/UAccounts.pas
  2. 4 2
      src/core/UPoolMining.pas

+ 9 - 2
src/core/UAccounts.pas

@@ -118,7 +118,7 @@ Type
     Class procedure SaveTOperationBlockToStream(const stream : TStream; const operationBlock:TOperationBlock);
     Class procedure SaveTOperationBlockToStream(const stream : TStream; const operationBlock:TOperationBlock);
     Class Function LoadTOperationBlockFromStream(const stream : TStream; var operationBlock:TOperationBlock) : Boolean;
     Class Function LoadTOperationBlockFromStream(const stream : TStream; var operationBlock:TOperationBlock) : Boolean;
     Class Function AccountToTxt(const Account : TAccount) : String;
     Class Function AccountToTxt(const Account : TAccount) : String;
-    Class Function AccountCanRecover(const Account: TAccount; currentBlockCount: Cardinal) : Boolean;
+    Class Function AccountCanRecover(const Account: TAccount; currentBlockCount: Cardinal; ASafeboxCurrentProtocol : Integer) : Boolean;
   End;
   End;
 
 
   TPCSafeBox = Class;
   TPCSafeBox = Class;
@@ -1777,7 +1777,7 @@ begin
       Account.account_data.ToHexaString,Account.account_seal.ToHexaString ]);
       Account.account_data.ToHexaString,Account.account_seal.ToHexaString ]);
 end;
 end;
 
 
-class function TAccountComp.AccountCanRecover(const Account: TAccount; currentBlockCount: Cardinal): Boolean;
+class function TAccountComp.AccountCanRecover(const Account: TAccount; currentBlockCount: Cardinal; ASafeboxCurrentProtocol : Integer) : Boolean;
 begin
 begin
   Result := True;
   Result := True;
   if TAccountComp.IsAccountBlockedByProtocol(Account.account, currentBlockCount) then begin
   if TAccountComp.IsAccountBlockedByProtocol(Account.account, currentBlockCount) then begin
@@ -1798,6 +1798,13 @@ begin
     Result := False; // 'account block is active';
     Result := False; // 'account block is active';
     Exit;
     Exit;
   end;
   end;
+  if (ASafeboxCurrentProtocol>CT_PROTOCOL_5) then begin
+    if (Account.balance>0) or (Length(Account.name)>0) then begin
+      Result := False; // 'Recover account is only valid for Balance 0 since Protocol 6'
+      exit;
+    end;
+  end;
+
 end;
 end;
 
 
 class function TAccountComp.IsValidAccountInfo(const AAccountInfo: TAccountInfo; ACurrentProtocol : Word; var errors: String): Boolean;
 class function TAccountComp.IsValidAccountInfo(const AAccountInfo: TAccountInfo; ACurrentProtocol : Word; var errors: String): Boolean;

+ 4 - 2
src/core/UPoolMining.pas

@@ -810,7 +810,9 @@ begin
       try
       try
         if (Not (TPCOperationsComp.EqualsOperationBlock(FMinerOperations.OperationBlock,LLockedMempool.OperationBlock))) then begin
         if (Not (TPCOperationsComp.EqualsOperationBlock(FMinerOperations.OperationBlock,LLockedMempool.OperationBlock))) then begin
           FMinerOperations.Clear(true);
           FMinerOperations.Clear(true);
-          CheckMinerRecover(LLockedMempool);
+          if LLockedMempool.SafeBoxTransaction.FreezedSafeBox.CurrentProtocol < CT_PROTOCOL_6 then begin
+            CheckMinerRecover(LLockedMempool);
+          end;
           if LLockedMempool.Count>0 then begin
           if LLockedMempool.Count>0 then begin
             // First round: Select with fee > 0
             // First round: Select with fee > 0
             i := 0;
             i := 0;
@@ -973,7 +975,7 @@ begin
         LRecoverAccountsCount := LAccOrd.Count;
         LRecoverAccountsCount := LAccOrd.Count;
         while ((LRecIndex < LRecoverAccountsCount) and (LRecIndex < CT_MAX_0_fee_operations_per_block_by_miner)) do begin
         while ((LRecIndex < LRecoverAccountsCount) and (LRecIndex < CT_MAX_0_fee_operations_per_block_by_miner)) do begin
           LAccount := FNodeNotifyEvents.Node.GetMempoolAccount(LIndexKey);
           LAccount := FNodeNotifyEvents.Node.GetMempoolAccount(LIndexKey);
-          if(TAccountComp.AccountCanRecover(LAccount, nbOperations.OperationBlock.block)) then begin // does the AccountCanRecover check, !locked, old enough, etc
+          if(TAccountComp.AccountCanRecover(LAccount, nbOperations.OperationBlock.block, nbOperations.bank.SafeBox.CurrentProtocol)) then begin // does the AccountCanRecover check, !locked, old enough, etc
             LRecoverAccounts.Add(LAccount);
             LRecoverAccounts.Add(LAccount);
           end else begin
           end else begin
             Break; // we could not recover this account, then we can never recover move recent accounts
             Break; // we could not recover this account, then we can never recover move recent accounts