Browse Source

Set PascalCoin core to use new AbstractMem v1.5 library

Albert Molina 3 years ago
parent
commit
6d95276c33
2 changed files with 9 additions and 9 deletions
  1. 2 2
      src/core/UPCAbstractMem.pas
  2. 7 7
      src/core/UPCAbstractMemAccountKeys.pas

+ 2 - 2
src/core/UPCAbstractMem.pas

@@ -404,7 +404,7 @@ begin
   end;
   end;
   if (Not FAbstractMem.ReadOnly) and (AIsNewStructure) then begin
   if (Not FAbstractMem.ReadOnly) and (AIsNewStructure) then begin
     // Initialize struct
     // Initialize struct
-    FAbstractMem.ClearContent;
+    FAbstractMem.ClearContent(False);
     LZone := FAbstractMem.New( CT_HEADER_MIN_SIZE );  // Header zone
     LZone := FAbstractMem.New( CT_HEADER_MIN_SIZE );  // Header zone
     SetLength(LHeader,100);
     SetLength(LHeader,100);
     FillChar(LHeader[0],Length(LHeader),0);
     FillChar(LHeader[0],Length(LHeader),0);
@@ -482,7 +482,7 @@ var
   LIsNewStructure : Boolean;
   LIsNewStructure : Boolean;
 begin
 begin
   FlushCache;
   FlushCache;
-  FAbstractMem.ClearContent;
+  FAbstractMem.ClearContent(False);
   DoInit(LIsNewStructure);
   DoInit(LIsNewStructure);
 end;
 end;
 
 

+ 7 - 7
src/core/UPCAbstractMemAccountKeys.pas

@@ -20,7 +20,7 @@ type
     myPosition :   TAbstractMemPosition;    // Position in the AbstractMem
     myPosition :   TAbstractMemPosition;    // Position in the AbstractMem
     accountKey : TAccountKey;
     accountKey : TAccountKey;
     accounts_using_this_key_position : TAbstractMemPosition;
     accounts_using_this_key_position : TAbstractMemPosition;
-    function GetSize : Integer;
+    function GetSize(AAbstractMem : TAbstractMem) : Integer;
     procedure ReadFromMem(AMyPosition : TAbstractMemPosition; AAbstractMem : TAbstractMem);
     procedure ReadFromMem(AMyPosition : TAbstractMemPosition; AAbstractMem : TAbstractMem);
     procedure WriteToMem(AAbstractMem : TAbstractMem);
     procedure WriteToMem(AAbstractMem : TAbstractMem);
     procedure Clear;
     procedure Clear;
@@ -133,9 +133,9 @@ begin
   Self.accounts_using_this_key_position := 0;
   Self.accounts_using_this_key_position := 0;
 end;
 end;
 
 
-function TAbstractMemAccountKeyNode.GetSize: Integer;
+function TAbstractMemAccountKeyNode.GetSize(AAbstractMem : TAbstractMem) : Integer;
 begin
 begin
-  Result := accountKey.GetSerializedLength + 4 + TAbstractMemAVLTreeNodeInfoClass.GetSize;
+  Result := accountKey.GetSerializedLength + 4 + TAbstractMemAVLTreeNodeInfoClass.GetSize(AAbstractMem);
 end;
 end;
 
 
 procedure TAbstractMemAccountKeyNode.ReadFromMem(AMyPosition: TAbstractMemPosition; AAbstractMem: TAbstractMem);
 procedure TAbstractMemAccountKeyNode.ReadFromMem(AMyPosition: TAbstractMemPosition; AAbstractMem: TAbstractMem);
@@ -145,7 +145,7 @@ var LBytes : TBytes;
 begin
 begin
   Self.Clear;
   Self.Clear;
   Self.myPosition := AMyPosition;
   Self.myPosition := AMyPosition;
-  inc(AMyPosition,TAbstractMemAVLTreeNodeInfoClass.GetSize);
+  inc(AMyPosition,TAbstractMemAVLTreeNodeInfoClass.GetSize(AAbstractMem));
   // Minimum size is  4 + 2 + 2 = 8 bytes
   // Minimum size is  4 + 2 + 2 = 8 bytes
   i := 8;
   i := 8;
   SetLength(LBytes,i);
   SetLength(LBytes,i);
@@ -180,7 +180,7 @@ begin
     LStream.Write(Self.accounts_using_this_key_position,4);
     LStream.Write(Self.accounts_using_this_key_position,4);
     Self.accountKey.ToSerialized(LStream);
     Self.accountKey.ToSerialized(LStream);
     LBytes.FromStream(LStream);
     LBytes.FromStream(LStream);
-    AAbstractMem.Write(Self.myPosition + TAbstractMemAVLTreeNodeInfoClass.GetSize,LBytes[0],Length(LBytes));
+    AAbstractMem.Write(Self.myPosition + TAbstractMemAVLTreeNodeInfoClass.GetSize(AAbstractMem),LBytes[0],Length(LBytes));
   finally
   finally
     LStream.Free;
     LStream.Free;
   end;
   end;
@@ -373,7 +373,7 @@ begin
     // if LNode does not exists, then ADD
     // if LNode does not exists, then ADD
     LNode.accountKey := AAccountKey;
     LNode.accountKey := AAccountKey;
     LNode.accounts_using_this_key_position := 0;
     LNode.accounts_using_this_key_position := 0;
-    LNode.myPosition := FAbstractMem.New( LNode.GetSize ).position;
+    LNode.myPosition := FAbstractMem.New( LNode.GetSize(FAbstractMem) ).position;
     LNode.WriteToMem(FAbstractMem);
     LNode.WriteToMem(FAbstractMem);
     Add(LNode);
     Add(LNode);
   end;
   end;
@@ -463,7 +463,7 @@ begin
     // if LNode does not exists, then ADD
     // if LNode does not exists, then ADD
     LNode.accountKey := AAccountKey;
     LNode.accountKey := AAccountKey;
     LNode.accounts_using_this_key_position := 0;
     LNode.accounts_using_this_key_position := 0;
-    LNode.myPosition := FAbstractMem.New( LNode.GetSize ).position;
+    LNode.myPosition := FAbstractMem.New( LNode.GetSize(FAbstractMem) ).position;
     LNode.WriteToMem(FAbstractMem);
     LNode.WriteToMem(FAbstractMem);
     Add(LNode);
     Add(LNode);
   end;
   end;