Browse Source

2.1.8

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
PascalCoin 7 years ago
parent
commit
3a81943524
3 changed files with 15 additions and 0 deletions
  1. 3 0
      README.md
  2. 7 0
      README.txt
  3. 5 0
      Units/PascalCoin/UFileStorage.pas

+ 3 - 0
README.md

@@ -34,6 +34,9 @@ Also, consider a donation at PascalCoin development account: "0-10"
 
 ## History:  
 
+### 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

+ 7 - 0
README.txt

@@ -34,6 +34,13 @@ Also, consider a donation at PascalCoin development account: "0-10"
 
 ## History:  
 
+### 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

+ 5 - 0
Units/PascalCoin/UFileStorage.pas

@@ -240,6 +240,9 @@ begin
     Stream.Position:=p;
     // Write null data until end of header
     GrowStreamUntilPos(Stream,FBlockHeadersFirstBytePosition[iBlockHeaders] + GetBlockHeaderFixedSize,true);
+    // Force to clean Block Headers future rows
+    SetLength(FBlockHeadersFirstBytePosition,iBlockHeaders+1); // Force to clear future blocks on next Block Headers row (Bug solved on 2.1.8)
+    FStreamLastBlockNumber:=Int64(StartingDeleteBlock)-1;
     // End Stream at _Header
     Stream.Size := Stream.Position + _Header.StreamBlockRelStartPos;
   Finally
@@ -917,6 +920,8 @@ begin
     Stream.Write(c,sizeof(_Header.BlockSize));
     // Positioning until Header end
     GrowStreamUntilPos(Stream,_StreamBlockHeaderStartPos + GetBlockHeaderFixedSize,true);
+    // If this is an override, force to clean Block Headers future rows
+    SetLength(FBlockHeadersFirstBytePosition,iBlockHeaders+1); // Force to clear future blocks on next Block Headers row (Bug solved on 2.1.8)
     // And now positioning until Data:
     GrowStreamUntilPos(Stream,_StreamBlockHeaderStartPos + GetBlockHeaderFixedSize + _Header.StreamBlockRelStartPos, false );
     {$IFDEF HIGHLOG}