Explorar o código

Merge pull request #35 from SkybuckFlying/GUIExperimentalBugFixes1

Gui experimental bug fixes1
Herman Schoenfeld %!s(int64=4) %!d(string=hai) anos
pai
achega
469e748c66

+ 3 - 0
src/core/UEncoding.pas

@@ -195,6 +195,9 @@ var
   i: Int32;
 begin
   Result := #0;
+  // carefull: E:\SourceCode\PascalCoin-master\src\libraries\regex must be added to project file
+  // otherwise wrong unit will be used from:
+  // Drive:\Tools\Lazarus\fpc\3.2.0\source\packages\regexpr\src
   i := FRegex.MatchIndexFromName(AGroupName);
   if i >= 0 then begin
     Result := FRegex.Match[i];

+ 21 - 16
src/gui-experimental/core.utils/UCoreUtils.pas

@@ -23,14 +23,14 @@ interface
 
 uses
   Classes, SysUtils, Forms, Dialogs, LCLType, UAccounts, UBlockChain, UNode, UWallet,
-  UBaseTypes, UCommon, UCoreObjects, UCommon.Collections, Generics.Defaults;
+  UBaseTypes, UCommon, UCoreObjects, UCommon.Collections, Generics.Defaults, UPCDataTypes;
 
 type
 
   { TAccountComparer }
 
   TAccountComparer = class(TComparer<TAccount>)
-    function Compare(constref ALeft, ARight: T): integer; override;
+    function Compare(constref ALeft, ARight: TAccount): integer; override;
     class function DoCompare(constref ALeft, ARight: TAccount): integer; inline;
   end;
 
@@ -47,7 +47,7 @@ type
   { TAccountKeyComparer }
 
   TAccountKeyComparer = class(TComparer<TAccountKey>)
-    function Compare(constref ALeft, ARight: T): integer; override;
+    function Compare(constref ALeft, ARight: TAccountKey): integer; override;
     class function DoCompare(constref ALeft, ARight: TAccountKey): integer; inline;
   end;
 
@@ -232,7 +232,7 @@ var
   i, j: integer;
   LAccs: TList<TAccount>;
   LAcc: TAccount;
-  LList: TOrderedCardinalList;
+  LList: TAccountsNumbersList;
   LMemPool: TPCOperationsComp;
   Disposables: TDisposables;
 begin
@@ -268,7 +268,7 @@ class function TCoreTool.GetUserAccountNumbers: TArray<cardinal>;
 var
   i, j: integer;
   LAccs: TSortedList<cardinal>;
-  LList: TOrderedCardinalList;
+  LList: TAccountsNumbersList;
   Disposables: TDisposables;
 begin
   LAccs := Disposables.AddObject(TSortedList<cardinal>.Create) as TSortedList<cardinal>;
@@ -478,7 +478,7 @@ var
 
   function GetAccountLastUpdateBlock(constref AAccount: TAccount): cardinal;
   begin
-    Result := AAccount.updated_block;
+    Result := AAccount.GetLastUpdatedBlock;
   end;
 
 begin
@@ -496,8 +496,8 @@ begin
     // if account is modified in block-tip
     LAcc := LAccounts[i];
     LAccountBalances.AddOrSetValue(LAcc.account, LAcc.Balance);  // track account balances
-    LBlockTraversal.Add(LAcc.updated_block);
-    MarkAccountAsScannableAtBlock(LAcc.account, LAcc.updated_block);
+    LBlockTraversal.Add(LAcc.GetLastUpdatedBlock);
+    MarkAccountAsScannableAtBlock(LAcc.account, LAcc.GetLastUpdatedBlock);
   end;
 
   // Traverse the set of "last updated" blocks in DESCENDING order
@@ -544,7 +544,7 @@ begin
   Result :=
     (ALeft.account = ARight.account) and
     (ALeft.balance = ARight.balance) and
-    (ALeft.updated_block = ARight.updated_block) and
+    (ALeft.GetLastUpdatedBlock = ARight.GetLastUpdatedBlock) and
     (ALeft.n_operation = ARight.n_operation) and
     TAccountKeyEqualityComparer.AreEqual(ALeft.accountInfo.accountKey, ARight.accountInfo.accountKey);
 end;
@@ -556,7 +556,7 @@ end;
 
 { TAccountKeyComparer }
 
-function TAccountKeyComparer.Compare(constref ALeft, ARight: T): integer;
+function TAccountKeyComparer.Compare(constref ALeft, ARight: TAccountKey): integer;
 begin
   Result := TAccountKeyComparer.DoCompare(ALeft, ARight);
 end;
@@ -614,7 +614,8 @@ begin
   builder.Append('');
   builder.Append(Format('Current balance: %s', [TAccountComp.FormatMoney(Self.balance)]));
   builder.Append('');
-  builder.Append(Format('Updated on block: %d  (%d blocks ago)', [Self.updated_block, ABank.BlocksCount - Self.updated_block]));
+  builder.Append(Format('Passively updated on block: %d  (%d blocks ago)', [Self.updated_on_block_passive_mode, ABank.BlocksCount - Self.updated_on_block_passive_mode]));
+  builder.Append(Format('Actively updated on block: %d  (%d blocks ago)', [Self.updated_on_block_active_mode, ABank.BlocksCount - Self.updated_on_block_active_mode]));
   builder.Append(Format('Public key type: %s', [TAccountComp.GetECInfoTxt(Self.accountInfo.accountKey.EC_OpenSSL_NID)]));
   builder.Append(Format('Base58 Public key: %s', [TAccountComp.AccountPublicKeyExport(Self.accountInfo.accountKey)]));
   if TAccountComp.IsAccountForSale(Self.accountInfo) then
@@ -623,7 +624,9 @@ begin
     builder.Append('** Account is for sale: **');
     builder.Append(Format('Price: %s', [TAccountComp.FormatMoney(Self.accountInfo.price)]));
     builder.Append(Format('Seller account (where to pay): %s', [TAccountComp.AccountNumberToAccountTxtNumber(Self.accountInfo.account_to_pay)]));
-    if TAccountComp.IsAccountForSaleAcceptingTransactions(Self.accountInfo) then
+//    if TAccountComp.IsAccountForSaleAcceptingTransactions(Self.accountInfo) then // Skybuck *old*
+    // Skybuck: reduced funtionality for now, might need fixing later.
+    if TAccountComp.IsAccountForSaleOrSwap(Self.accountInfo) then // Skybuck *new*
     begin
       builder.Append('');
       builder.Append('** Private sale **');
@@ -669,12 +672,12 @@ begin
   builder.Add(Format('Operation Hash (ophash): %s', [TCrypto.ToHexaString(Self.OperationHash)]));
   if (Self.OperationHash_OLD <> nil) then
     builder.Add(Format('Old Operation Hash (old_ophash): %s', [TCrypto.ToHexaString(Self.OperationHash_OLD)]));
-  if (Self.OriginalPayload <> nil) then
+  if (Self.OriginalPayload.payload_raw <> nil) then
   begin
-    builder.Add(Format('Payload length:%d', [length(Self.OriginalPayload)]));
+    builder.Add(Format('Payload length:%d', [length(Self.OriginalPayload.payload_raw)]));
     if Self.PrintablePayload <> '' then
       builder.Add(Format('Payload (human): %s', [Self.PrintablePayload]));
-    builder.Add(Format('Payload (Hexadecimal): %s', [TCrypto.ToHexaString(Self.OriginalPayload)]));
+    builder.Add(Format('Payload (Hexadecimal): %s', [TCrypto.ToHexaString(Self.OriginalPayload.payload_raw)]));
   end;
   if Self.Balance >= 0 then
     builder.Add(Format('Final balance: %s', [TAccountComp.FormatMoney(Self.Balance)]));
@@ -1587,6 +1590,7 @@ var
   LAccountIdx, LNoOfOperations, LAccNumberIndex: integer;
   LCurrentAccount, LSignerAccount: TAccount;
   LPayloadEncodedBytes, LNewName: TRawBytes;
+  LOperationPayload : TOperationPayload;
 begin
 
   LWalletKeys := TWallet.Keys;
@@ -1644,8 +1648,9 @@ begin
         Exit(False);
       end;
 
+      LOperationPayload.payload_raw := LPayloadEncodedBytes;
       LPCOperation := TOpBuyAccount.CreateBuy(LNode.Bank.Safebox.CurrentProtocol, LCurrentAccount.account, LCurrentAccount.n_operation + 1, AAccountToBuy.account, AAccountToBuy.accountInfo.account_to_pay,
-        AAccountToBuy.accountInfo.price, AAmount, LFee, ANewOwnerPublicKey, LWalletKey.PrivateKey, LPayloadEncodedBytes);
+        AAccountToBuy.accountInfo.price, AAmount, LFee, ANewOwnerPublicKey, LWalletKey.PrivateKey, LOperationPayload);
 
       try
       LTemp := Format('%d. Buy Account %s for %s PASC %s', [LNoOfOperations + 1, AAccountToBuy.AccountString, TAccountComp.FormatMoney(AAmount), sLineBreak]);

+ 3 - 0
src/libraries/sphere10/UCommon.Data.pas

@@ -675,6 +675,8 @@ begin
     end;
   end;
 
+  (*
+  // Skybuck: Free Pascal Compiler Bug/Internal Error 2015052501 (disabled for now).
   case filters.Count of
     0: Result := nil;
     1: Result := filters[0];
@@ -683,6 +685,7 @@ begin
       foOr: Result := __TPredicateTool_T.OrMany(filters.ToArray);
     end;
   end;
+  *)
 end;
 
 { TPageFetchParams }

+ 17 - 5
src/pascalcoin_wallet_experimental.lpi

@@ -1,16 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="12"/>
+    <Version Value="11"/>
     <PathDelim Value="\"/>
     <General>
       <Flags>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
         <MainUnitHasCreateFormStatements Value="False"/>
         <MainUnitHasTitleStatement Value="False"/>
-        <CompatibilityMode Value="True"/>
       </Flags>
       <SessionStorage Value="InProjectDir"/>
+      <MainUnit Value="0"/>
       <Title Value="PascalCoin Wallet"/>
       <ResourceType Value="res"/>
     </General>
@@ -28,7 +28,7 @@
           </Target>
           <SearchPaths>
             <IncludeFiles Value="$(ProjOutDir);libraries\generics.collections\inc"/>
-            <OtherUnitFiles Value="core;gui-experimental;libraries\synapse;libraries\abstractmem;\libraries\regex;libraries\sphere10;libraries\simplebaselib4pascal;libraries\cryptolib4pascal;libraries\hashlib4pascal;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;gui-classic;libraries\paszlib"/>
+            <OtherUnitFiles Value="core;gui-experimental;libraries\synapse;libraries\abstractmem;\libraries\regex;libraries\sphere10;libraries\simplebaselib4pascal;libraries\cryptolib4pascal;libraries\hashlib4pascal;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;gui-classic;libraries\paszlib;libraries\regex"/>
             <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
           </SearchPaths>
           <Parsing>
@@ -77,7 +77,7 @@
         <PackageName Value="LCL"/>
       </Item1>
     </RequiredPackages>
-    <Units Count="104">
+    <Units Count="107">
       <Unit0>
         <Filename Value="pascalcoin_wallet_experimental.dpr"/>
         <IsPartOfProject Value="True"/>
@@ -642,6 +642,18 @@
         <Filename Value="core\URandomHash2.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit103>
+      <Unit104>
+        <Filename Value="libraries\abstractmem\UAbstractMem.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit104>
+      <Unit105>
+        <Filename Value="core\UEncoding.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit105>
+      <Unit106>
+        <Filename Value="libraries\regex\uregexpr.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit106>
     </Units>
   </ProjectOptions>
   <CompilerOptions>
@@ -652,7 +664,7 @@
     </Target>
     <SearchPaths>
       <IncludeFiles Value="$(ProjOutDir);libraries\generics.collections\inc"/>
-      <OtherUnitFiles Value="core;gui-experimental;libraries\simplebaselib4pascal;libraries\hashlib4pascal;libraries\cryptolib4pascal;libraries\synapse;libraries\sphere10;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;libraries\paszlib;gui-classic"/>
+      <OtherUnitFiles Value="core;gui-experimental;libraries\simplebaselib4pascal;libraries\hashlib4pascal;libraries\cryptolib4pascal;libraries\synapse;libraries\sphere10;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;libraries\paszlib;gui-classic;libraries\abstractmem;libraries\regex"/>
       <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
     <Parsing>