Browse Source

Param -b MAX_BLOCK_NUMBER

Allow to force max block read from Blockchain when started using "-b
MAX_BLOCK_NUMBER" param
PascalCoin 7 years ago
parent
commit
5f8d0f50d4
3 changed files with 24 additions and 4 deletions
  1. 12 0
      README.md
  2. 3 3
      src/core/UNode.pas
  3. 9 1
      src/core/upcdaemon.pas

+ 12 - 0
README.md

@@ -167,12 +167,24 @@ Also, consider a donation at PascalCoin development account: "0-10"
       - "operations" : Integer
       - "amount" : PASCURRENCY
       - "fee" : PASCURRENCY  
+- Daemon:
+  - Allow to force max block read from Blockchain when started using "-b MAX_BLOCK_NUMBER" param. Example "nohup ./pascalcoin_daemon -r -b 12345 &"
 - Protections against invalid nodes (scammers):
   - Protection on GetBlocks and GetBlockOperations
 - Merged new GUI with current stable core
 - New folders organization
 - Bugs solved
 
+### Build 2.1.9 - 2018-04-16
+- Searchs last valid block found on corrupted BlockChainStream.blocks file and allows to continue from last valid one. On prior versions, app halted and needed manually file deletion
+
+### Build 2.1.8 - 2018-04-16
+- Solved bug that can cause to corrupt BlockChainStream.blocks file when detecting an orphan block and creating new BlockHeaders row (every 1000 blocks). Very rare bug, but fatal error
+
+### Build 2.1.7 - 2018-04-10
+- Remove use of TPCOperation.FSignatureChecked introduced on 2.1.6 because is not 100% secure
+- Minor bugs
+
 ### Build 2.1.6 - 2018-02-14
 - Important improvements
   - Improved speed when processing operations on start

+ 3 - 3
src/core/UNode.pas

@@ -87,7 +87,7 @@ Type
     Function FindNOperation(block, account, n_operation : Cardinal; var OpResume : TOperationResume) : TSearchOperationResult;
     Function FindNOperations(account, start_block : Cardinal; allow_search_previous : Boolean; n_operation_low, n_operation_high : Cardinal; OpResumeList : TOperationsResumeList) : TSearchOperationResult;
     //
-    Procedure InitSafeboxAndOperations;
+    Procedure InitSafeboxAndOperations(max_block_to_read : Cardinal = $FFFFFFFF);
     Procedure AutoDiscoverNodes(Const ips : AnsiString);
     Function IsBlockChainValid(var WhyNot : AnsiString) : Boolean;
     Function IsReady(Var CurrentProcess : AnsiString) : Boolean;
@@ -931,13 +931,13 @@ begin
   Result := found;
 end;
 
-procedure TNode.InitSafeboxAndOperations;
+procedure TNode.InitSafeboxAndOperations(max_block_to_read : Cardinal);
 var opht : TOperationsHashTree;
   oprl : TOperationsResumeList;
   errors : AnsiString;
   n : Integer;
 begin
-  Bank.DiskRestoreFromOperations(CT_MaxBlock);
+  Bank.DiskRestoreFromOperations(max_block_to_read);
   opht := TOperationsHashTree.Create;
   oprl := TOperationsResumeList.Create;
   try

+ 9 - 1
src/core/upcdaemon.pas

@@ -44,11 +44,13 @@ Type
   TPCDaemonThread = Class(TPCThread)
   private
     FIniFile : TIniFile;
+    FMaxBlockToRead: Int64;
   protected
     Procedure BCExecute; override;
   public
     constructor Create;
     destructor Destroy; override;
+    property MaxBlockToRead : Int64 read FMaxBlockToRead write FMaxBlockToRead;
   end;
 
   { TPCDaemon }
@@ -205,7 +207,7 @@ begin
         FNode.Bank.StorageClass := TFileStorage;
         TFileStorage(FNode.Bank.Storage).DatabaseFolder := TFolderHelper.GetPascalCoinDataFolder+PathDelim+'Data';
         // Reading database
-        FNode.InitSafeboxAndOperations;
+        FNode.InitSafeboxAndOperations(MaxBlockToRead);
         FWalletKeys.SafeBox := FNode.Node.Bank.SafeBox;
         FNode.Node.NetServer.Port:=FIniFile.ReadInteger(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_NODE_PORT,CT_NetServer_Port);
         FNode.Node.NetServer.MaxConnections:=FIniFile.ReadInteger(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_NODE_MAX_CONNECTIONS,CT_MaxClientsConnected);
@@ -248,6 +250,8 @@ begin
   end else begin
     FIniFile.WriteBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_SAVELOGS,false);
   end;
+  FMaxBlockToRead:=$FFFFFFFF;
+  TLog.NewLog(ltinfo,ClassName,'Create');
 end;
 
 destructor TPCDaemonThread.Destroy;
@@ -271,6 +275,10 @@ begin
   FThread:=TPCDaemonThread.Create;
   FThread.OnTerminate:=@ThreadStopped;
   FThread.FreeOnTerminate:=False;
+  if (Application.HasOption('b','block')) then begin
+    FThread.MaxBlockToRead:=StrToInt64Def(Application.GetOptionValue('b','block'),$FFFFFFFF);
+    TLog.NewLog(ltinfo,ClassName,'Max block to read: '+IntToStr(FThread.MaxBlockToRead));
+  end;
   FThread.Resume;
 end;