Browse Source

Restructure: resources folder

Herman Schoenfeld 7 years ago
parent
commit
7cbca03f21

+ 0 - 0
Resources/WalletImages/PascalCoin.ico → resources/wallet/PascalCoin.ico


+ 0 - 0
Resources/WalletImages/banner-bg-800x80.png → resources/wallet/banner-bg-800x80.png


+ 0 - 0
Resources/WalletImages/clipboard-24x24.png → resources/wallet/clipboard-24x24.png


+ 0 - 0
Resources/WalletImages/lock-16x16.png → resources/wallet/lock-16x16.png


+ 0 - 0
Resources/WalletImages/logo-1000x1000.png → resources/wallet/logo-1000x1000.png


+ 0 - 0
Resources/WalletImages/logo-64x64.png → resources/wallet/logo-64x64.png


+ 0 - 0
Resources/WalletImages/logo-design.pdn → resources/wallet/logo-design.pdn


+ 0 - 0
Resources/WalletImages/logo-testnet-1000x1000.png → resources/wallet/logo-testnet-1000x1000.png


+ 0 - 0
Resources/WalletImages/logo-testnet-64x64.png → resources/wallet/logo-testnet-64x64.png


+ 0 - 0
Resources/WalletImages/logo-text-284x64.png → resources/wallet/logo-text-284x64.png


+ 0 - 0
Resources/WalletImages/minus-16x16.png → resources/wallet/minus-16x16.png


+ 0 - 0
Resources/WalletImages/network-off-16x16.png → resources/wallet/network-off-16x16.png


+ 0 - 0
Resources/WalletImages/network-on-16x16.png → resources/wallet/network-on-16x16.png


+ 0 - 0
Resources/WalletImages/plus-16x16.png → resources/wallet/plus-16x16.png


+ 0 - 0
Resources/WalletImages/search-16x16.png → resources/wallet/search-16x16.png


+ 0 - 0
Resources/WalletImages/success-64x64.png → resources/wallet/success-64x64.png


+ 0 - 0
Resources/WalletImages/sync-16x16.png → resources/wallet/sync-16x16.png


+ 0 - 0
Resources/WalletImages/testnet-logo-text-284x64.png → resources/wallet/testnet-logo-text-284x64.png


+ 0 - 0
Resources/WalletImages/unlock-64x64.png → resources/wallet/unlock-64x64.png


+ 0 - 0
Resources/WalletImages/unlock-red-64x64.png → resources/wallet/unlock-red-64x64.png


+ 0 - 0
Resources/WalletImages/wallet-locked-16x16.png → resources/wallet/wallet-locked-16x16.png


+ 0 - 0
Resources/WalletImages/wallet-unlocked-16x16.png → resources/wallet/wallet-unlocked-16x16.png


+ 25 - 32
src/core/UBlockChain.pas

@@ -190,6 +190,8 @@ Type
   Private
     Ftag: integer;
   Protected
+    FSignatureChecked : Boolean; // Improvement TPCOperation speed 2.1.6
+    //
     FPrevious_Signer_updated_block: Cardinal;
     FPrevious_Destination_updated_block : Cardinal;
     FPrevious_Seller_updated_block : Cardinal;
@@ -215,7 +217,6 @@ Type
     function OperationFee: UInt64; virtual; abstract;
     function OperationPayload : TRawBytes; virtual; abstract;
     function SignerAccount : Cardinal; virtual; abstract;
-    procedure SignerAccounts(list : TList); virtual;
     function IsSignerAccount(account : Cardinal) : Boolean; virtual;
     function IsAffectedAccount(account : Cardinal) : Boolean; virtual;
     function DestinationAccount : Int64; virtual;
@@ -648,6 +649,10 @@ begin
       Storage.Initialize;
       If (max_block<Storage.LastBlock) then n := max_block
       else n := Storage.LastBlock;
+//      if n < 0 then begin
+//        NewLog(nil,lterror,'Unable to load storage');
+//        exit;
+//      end;
       Storage.RestoreBank(n);
       // Restore last blockchain
       if (BlocksCount>0) And (SafeBox.CurrentProtocol=CT_PROTOCOL_1) then begin
@@ -1853,8 +1858,7 @@ begin
       for i := 0 to l.Count - 1 do begin
         P := l[i];
         // Include to hash tree
-        // TCrypto.DoSha256(FHashTree+P^.Op.Sha256,FHashTree);  COMPILER BUG 2.1.6: Using FHashTree as a "out" param can be initialized prior to be updated first parameter!
-        FHashTree := TCrypto.DoSha256(FHashTree+P^.Op.Sha256);
+        TCrypto.DoSha256(FHashTree+P^.Op.Sha256,FHashTree);
       end;
     Finally
       FHashTreeOperations.UnlockList;
@@ -1938,8 +1942,8 @@ Var msCopy : TMemoryStream;
   h : TRawBytes;
   P : POperationHashTreeReg;
   PaccData : POperationsHashAccountsData;
-  i,npos,iListSigners : Integer;
-  listSigners : TList;
+  i,npos : Integer;
+  auxs : AnsiString;
 begin
   msCopy := TMemoryStream.Create;
   try
@@ -1952,14 +1956,15 @@ begin
     P^.Op.FPrevious_Signer_updated_block := op.Previous_Signer_updated_block;
     P^.Op.FPrevious_Destination_updated_block := op.FPrevious_Destination_updated_block;
     P^.Op.FPrevious_Seller_updated_block := op.FPrevious_Seller_updated_block;
-    h := FHashTree + op.Sha256;
+    P^.Op.FHasValidSignature:=op.FHasValidSignature;
+    P^.Op.FSignatureChecked:=op.FSignatureChecked;
+    h := op.Sha256;
     P^.Op.FBufferedSha256:=op.FBufferedSha256;
     P^.Op.tag := list.Count;
     // Improvement TOperationsHashTree speed 2.1.6
     // Include to hash tree (Only if CalcNewHashTree=True)
     If (CalcNewHashTree) And (Length(FHashTree)=32) then begin
-      // TCrypto.DoSha256(FHashTree+op.Sha256,FHashTree);  COMPILER BUG 2.1.6: Using FHashTree as a "out" param can be initialized prior to be updated first parameter!
-      TCrypto.DoSha256(h,FHashTree);
+      TCrypto.DoSha256(FHashTree+h,FHashTree);
     end;
     npos := list.Add(P);
     // Improvement: Will allow to add duplicate Operations, so add only first to orderedBySha
@@ -1969,24 +1974,16 @@ begin
     end;
     // Improvement TOperationsHashTree speed 2.1.6
     // Mantain an ordered Accounts list with data
-    listSigners := TList.Create;
-    try
-      op.SignerAccounts(listSigners);
-      for iListSigners:=0 to listSigners.Count-1 do begin
-        If Not FindOrderedByAccountData(list,PtrInt(listSigners[iListSigners]),i) then begin
-          New(PaccData);
-          PaccData^.account_number:=PtrInt(listSigners[iListSigners]);
-          PaccData^.account_count:=0;
-          PaccData^.account_without_fee:=0;
-          FListOrderedByAccountsData.Insert(i,PaccData);
-        end else PaccData := FListOrderedByAccountsData[i];
-        Inc(PaccData^.account_count);
-        If op.OperationFee=0 then begin
-          Inc(PaccData^.account_without_fee);
-        end;
-      end;
-    finally
-      listSigners.Free;
+    If Not FindOrderedByAccountData(list,op.SignerAccount,i) then begin
+      New(PaccData);
+      PaccData^.account_number:=op.SignerAccount;
+      PaccData^.account_count:=0;
+      PaccData^.account_without_fee:=0;
+      FListOrderedByAccountsData.Insert(i,PaccData);
+    end else PaccData := FListOrderedByAccountsData[i];
+    Inc(PaccData^.account_count);
+    If op.OperationFee=0 then begin
+      Inc(PaccData^.account_without_fee);
     end;
   finally
     msCopy.Free;
@@ -2250,6 +2247,7 @@ end;
 
 constructor TPCOperation.Create;
 begin
+  FSignatureChecked := False;
   FHasValidSignature := False;
   FBufferedSha256:='';
   InitializeData;
@@ -2284,12 +2282,6 @@ begin
   end else Raise Exception.Create('ERROR DEV 20170426-1'); // This should never happen, if good coded
 end;
 
-procedure TPCOperation.SignerAccounts(list: TList);
-begin
-  list.Clear;
-  list.Add(TObject(SignerAccount));
-end;
-
 class function TPCOperation.DecodeOperationHash(const operationHash: TRawBytes;
   var block, account, n_operation: Cardinal; var md160Hash : TRawBytes) : Boolean;
   { Decodes a previously generated OperationHash }
@@ -2366,6 +2358,7 @@ begin
   FPrevious_Seller_updated_block := 0;
   FHasValidSignature := false;
   FBufferedSha256:='';
+  FSignatureChecked := False;
 end;
 
 procedure TPCOperation.FillOperationResume(Block: Cardinal; getInfoForAllAccounts : Boolean; Affected_account_number: Cardinal; var OperationResume: TOperationResume);

+ 3 - 2
src/core/UFileStorage.pas

@@ -80,7 +80,7 @@ Type
     Class Function GetSafeboxCheckpointingFileName(Const BaseDataFolder : AnsiString; block : Cardinal) : AnsiString;
     Property DatabaseFolder : AnsiString read FDatabaseFolder write SetDatabaseFolder;
     Procedure CopyConfiguration(Const CopyFrom : TStorage); override;
-    Procedure SetBlockChainFile(BlockChainFileName : AnsiString);
+    Procedure SetBlockChainFile(const BlockChainFileName : AnsiString);
     Function HasUpgradedToVersion2 : Boolean; override;
     Procedure CleanupVersion1Data; override;
   End;
@@ -702,6 +702,7 @@ function TFileStorage.LockBlockChainStream: TFileStream;
     end;
     mem := TMemoryStream.Create;
     Try
+      iPos := Stream.Size;
       iPos := 0;
       while (iPos + GetBlockHeaderFixedSize < Stream.Size) do begin
         Stream.Position := iPos;
@@ -798,7 +799,7 @@ begin
   Result := FBlockChainStream;
 end;
 
-procedure TFileStorage.SetBlockChainFile(BlockChainFileName: AnsiString);
+procedure TFileStorage.SetBlockChainFile(const BlockChainFileName: AnsiString);
 begin
   ClearStream;
   FBlockChainFileName := BlockChainFileName;