|
@@ -148,22 +148,22 @@ An account history is composed of a chronological order of account events. An ac
|
|
|
end;
|
|
|
|
|
|
function IsValidAccountHistory(const AHistory : TAccountHistory) : Boolean;
|
|
|
- var
|
|
|
- LPrevSeg : TAccountSegment; // note: this is confusingly called TBlockAccount in implementation (should be changed, IMO)
|
|
|
+ var
|
|
|
+ LAccount : TAccount;
|
|
|
LActualPriorSafeBoxState : TBytes;
|
|
|
begin
|
|
|
|
|
|
// validate in reverse
|
|
|
- for i := Length(History) - 1 downto 1 do begin
|
|
|
- LAccount := History[i].AccountState;
|
|
|
- LPriorEvent := History[i-1];
|
|
|
+ for i := Length(AHistory) - 1 downto 1 do begin
|
|
|
+ LAccount := AHistory[i].AccountState;
|
|
|
+ LPriorEvent := AHistory[i-1];
|
|
|
if NOT FetchSafeBoxState(LPriorEvent.LastBlockNum, out LActualPriorSafeBoxState)
|
|
|
exit(false); // prior event referred to non-existent "last block num"
|
|
|
|
|
|
- if LPriorEvent.SafeBoxRoot <> LActualPriorRoot then
|
|
|
+ if LPriorEvent.SafeBoxRoot <> LActualPriorSafeBoxState then
|
|
|
exit(false); // prior event referred to invalid "safebox state"
|
|
|
|
|
|
- if LAccount.Seal <> CalculateSeal(LPriorEvent.AccountState, LPriorEvent.OPID, LPriorEvent.SafeBoxRoot) then
|
|
|
+ if LAccount.Seal <> CalculateSeal(LPriorEvent.AccountState, LPriorEvent.OPID, LPriorEvent.SafeBoxState ) then
|
|
|
exit(false); // prior event did not result in current account state
|
|
|
end;
|
|
|
// account history is valid
|
|
@@ -171,12 +171,12 @@ An account history is composed of a chronological order of account events. An ac
|
|
|
end
|
|
|
|
|
|
|
|
|
- function CalculateSeal( AccountSate : TAccount; PriorSafeBoxState: TBytes; MutatingOPID : TBytes ) : TBytes;
|
|
|
+ function CalculateSeal( PriorAccountState : TAccount; PriorSafeBoxState: TBytes; MutatingOPID : TBytes ) : TBytes;
|
|
|
begin
|
|
|
- return RIPEMD160 ( SHA2_256 ( Array.Join( PriorSafeBoxState, SerializeAccount ( AccountSate ), MutatingOPID ) ) );
|
|
|
+ return RIPEMD160 ( SHA2_256 ( Array.Join( PriorSafeBoxState, SerializeAccount ( PriorAccountState ), MutatingOPID ) ) );
|
|
|
end
|
|
|
|
|
|
- function SerializeAccount(account : TAccount) : TBytes;
|
|
|
+ function SerializeAccount(Account : TAccount) : TBytes;
|
|
|
begin
|
|
|
// as per network protocol
|
|
|
end
|