Browse Source

core files -> TRawBytes

PascalCoin 6 years ago
parent
commit
7ec2907653
3 changed files with 13 additions and 13 deletions
  1. 5 5
      src/core/UChunk.pas
  2. 1 1
      src/core/UPCOrderedLists.pas
  3. 7 7
      src/core/USettings.pas

+ 5 - 5
src/core/UChunk.pas

@@ -36,7 +36,7 @@ uses
   {$ELSE}
   {$ELSE}
   zlib,
   zlib,
   {$ENDIF}
   {$ENDIF}
-  UAccounts, ULog, UConst, UCrypto;
+  UAccounts, ULog, UConst, UCrypto, UBaseTypes;
 
 
 type
 type
 
 
@@ -84,7 +84,7 @@ begin
     TLog.NewLog(ltDebug,ClassName,Format('Saving safebox chunk from %d to %d (current blockscount: %d)',[FromBlock,ToBlock,sbHeader.blocksCount]));
     TLog.NewLog(ltDebug,ClassName,Format('Saving safebox chunk from %d to %d (current blockscount: %d)',[FromBlock,ToBlock,sbHeader.blocksCount]));
 
 
     // Header:
     // Header:
-    TStreamOp.WriteAnsiString(DestStream,CT_SafeBoxChunkIdentificator);
+    TStreamOp.WriteAnsiString(DestStream,TEncoding.ASCII.GetBytes(CT_SafeBoxChunkIdentificator));
     DestStream.Write(CT_SafeBoxBankVersion,SizeOf(CT_SafeBoxBankVersion));
     DestStream.Write(CT_SafeBoxBankVersion,SizeOf(CT_SafeBoxBankVersion));
     //
     //
     auxStream := TMemoryStream.Create;
     auxStream := TMemoryStream.Create;
@@ -126,7 +126,7 @@ begin
 end;
 end;
 
 
 class function TPCChunk.LoadSafeBoxFromChunk(Chunk, DestStream: TStream; var safeBoxHeader : TPCSafeBoxHeader; var errors: AnsiString): Boolean;
 class function TPCChunk.LoadSafeBoxFromChunk(Chunk, DestStream: TStream; var safeBoxHeader : TPCSafeBoxHeader; var errors: AnsiString): Boolean;
-var s : AnsiString;
+var raw : TRawBytes;
   w : Word;
   w : Word;
   cUncompressed, cCompressed : Cardinal;
   cUncompressed, cCompressed : Cardinal;
   ds : Tdecompressionstream;
   ds : Tdecompressionstream;
@@ -138,8 +138,8 @@ begin
   safeBoxHeader := CT_PCSafeBoxHeader_NUL;
   safeBoxHeader := CT_PCSafeBoxHeader_NUL;
   // Header:
   // Header:
   errors := 'Invalid stream header';
   errors := 'Invalid stream header';
-  TStreamOp.ReadAnsiString(Chunk,s);
-  If (s<>CT_SafeBoxChunkIdentificator) then begin
+  TStreamOp.ReadAnsiString(Chunk,raw);
+  If (Not TBaseType.Equals(raw,TEncoding.ASCII.GetBytes(CT_SafeBoxChunkIdentificator))) then begin
     exit;
     exit;
   end;
   end;
   Chunk.Read(w,sizeof(w));
   Chunk.Read(w,sizeof(w));

+ 1 - 1
src/core/UPCOrderedLists.pas

@@ -424,7 +424,7 @@ Var i : Integer;
 begin
 begin
   for i:=0 to FList.Count-1 do begin
   for i:=0 to FList.Count-1 do begin
     P := FList[i];
     P := FList[i];
-    P^.rawData:='';
+    SetLength(P^.rawData,0);
     Dispose(P);
     Dispose(P);
   end;
   end;
   FList.Clear;
   FList.Clear;

+ 7 - 7
src/core/USettings.pas

@@ -78,8 +78,8 @@ type
       class procedure SetDefaultFee(AInt64: Int64); static;
       class procedure SetDefaultFee(AInt64: Int64); static;
       class function GetMinerPrivateKeyType : TMinerPrivateKeyType; static;
       class function GetMinerPrivateKeyType : TMinerPrivateKeyType; static;
       class procedure SetMinerPrivateKeyType(AType: TMinerPrivateKeyType); static;
       class procedure SetMinerPrivateKeyType(AType: TMinerPrivateKeyType); static;
-      class function GetMinerSelectedPrivateKey : string; static;
-      class procedure SetMinerSelectedPrivateKey(AKey:string); static;
+      class function GetMinerSelectedPrivateKey : TRawBytes; static;
+      class procedure SetMinerSelectedPrivateKey(AKey:TRawBytes); static;
       class function GetMinerServerRpcActive : boolean; static;
       class function GetMinerServerRpcActive : boolean; static;
       class procedure SetMinerServerRpcActive(ABool: Boolean); static;
       class procedure SetMinerServerRpcActive(ABool: Boolean); static;
       class function GetMinerServerRpcPort : Integer; static;
       class function GetMinerServerRpcPort : Integer; static;
@@ -113,7 +113,7 @@ type
       class property RpcAllowedIPs : string read GetRpcAllowedIPs write SetRpcAllowedIPs;
       class property RpcAllowedIPs : string read GetRpcAllowedIPs write SetRpcAllowedIPs;
       class property DefaultFee : Int64 read GetDefaultFee write SetDefaultFee;
       class property DefaultFee : Int64 read GetDefaultFee write SetDefaultFee;
       class property MinerPrivateKeyType : TMinerPrivateKeyType read GetMinerPrivateKeyType write SetMinerPrivateKeyType;
       class property MinerPrivateKeyType : TMinerPrivateKeyType read GetMinerPrivateKeyType write SetMinerPrivateKeyType;
-      class property MinerSelectedPrivateKey : string read GetMinerSelectedPrivateKey write SetMinerSelectedPrivateKey;
+      class property MinerSelectedPrivateKey : TRawBytes read GetMinerSelectedPrivateKey write SetMinerSelectedPrivateKey;
       class property MinerServerRpcActive : boolean read GetMinerServerRpcActive write SetMinerServerRpcActive;
       class property MinerServerRpcActive : boolean read GetMinerServerRpcActive write SetMinerServerRpcActive;
       class property MinerServerRpcPort : Integer read GetMinerServerRpcPort write SetMinerServerRpcPort;
       class property MinerServerRpcPort : Integer read GetMinerServerRpcPort write SetMinerServerRpcPort;
       class property SaveLogFiles : boolean read GetSaveLogFiles write SetSaveLogFiles;
       class property SaveLogFiles : boolean read GetSaveLogFiles write SetSaveLogFiles;
@@ -256,16 +256,16 @@ begin
   FAppParams.ParamByName[CT_PARAM_MinerPrivateKeyType].SetAsInteger(Integer(AType));
   FAppParams.ParamByName[CT_PARAM_MinerPrivateKeyType].SetAsInteger(Integer(AType));
 end;
 end;
 
 
-class function TSettings.GetMinerSelectedPrivateKey : string;
+class function TSettings.GetMinerSelectedPrivateKey : TRawBytes;
 begin
 begin
   CheckLoaded;
   CheckLoaded;
-  Result := FAppParams.ParamByName[CT_PARAM_MinerPrivateKeySelectedPublicKey].GetAsString('');
+  Result := FAppParams.ParamByName[CT_PARAM_MinerPrivateKeySelectedPublicKey].GetAsTBytes(Nil);
 end;
 end;
 
 
-class procedure TSettings.SetMinerSelectedPrivateKey(AKey:string);
+class procedure TSettings.SetMinerSelectedPrivateKey(AKey:TRawBytes);
 begin
 begin
   CheckLoaded;
   CheckLoaded;
-  FAppParams.ParamByName[CT_PARAM_MinerPrivateKeySelectedPublicKey].SetAsString(AKey);
+  FAppParams.ParamByName[CT_PARAM_MinerPrivateKeySelectedPublicKey].SetAsTBytes(AKey);
 end;
 end;
 
 
 class function TSettings.GetSaveLogFiles : boolean;
 class function TSettings.GetSaveLogFiles : boolean;