|
@@ -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);
|