internal ActionEvaluation EvaluateBlockAction( Block <T> block, IReadOnlyList <ActionEvaluation> txActionEvaluations, StateCompleterSet <T> stateCompleters, ITrie?previousBlockStatesTrie ) { if (block == null) { throw new ArgumentNullException(nameof(block)); } if (_blockAction is null) { var message = "To evaluate block action, Policy.BlockAction must not be null."; throw new InvalidOperationException(message); } _logger.Debug( "Evaluating block action in block {blockIndex}: {block}", block?.Index, block); IAccountStateDelta?lastStates = null; if (!(txActionEvaluations is null) && txActionEvaluations.Count > 0) { lastStates = txActionEvaluations[txActionEvaluations.Count - 1].OutputStates; } Address miner = block !.Miner.GetValueOrDefault(); if (lastStates is null) { IValue?GetState(Address a) => _stateGetter(a, block.PreviousHash, stateCompleters.StateCompleter); FungibleAssetValue GetBalance(Address address, Currency currency) => _balanceGetter( address, currency, block.PreviousHash, stateCompleters.FungibleAssetStateCompleter ); lastStates = block.ProtocolVersion > 0 ? new AccountStateDeltaImpl(GetState, GetBalance, miner) : new AccountStateDeltaImplV0(GetState, GetBalance, miner); } return(ActionEvaluation.EvaluateActionsGradually( block.PreEvaluationHash, block.Index, null, lastStates, miner, miner, Array.Empty <byte>(), new[] { _blockAction }.ToImmutableList(), previousBlockStatesTrie: previousBlockStatesTrie, blockAction: true).First()); }
internal ActionEvaluation EvaluateBlockAction( Block <T> block, IReadOnlyList <ActionEvaluation> txActionEvaluations) { if (Policy.BlockAction is null) { var message = "To evaluate block action, Policy.BlockAction must not be null."; throw new InvalidOperationException(message); } IAccountStateDelta lastStates = null; if (!(txActionEvaluations is null) && txActionEvaluations.Count > 0) { lastStates = txActionEvaluations[txActionEvaluations.Count - 1].OutputStates; } Address miner = block.Miner.GetValueOrDefault(); if (lastStates is null) { lastStates = new AccountStateDeltaImpl( a => GetStates(new[] { a }, block.PreviousHash).GetValueOrDefault(a)); } return(ActionEvaluation.EvaluateActionsGradually( block.Hash, block.Index, null, lastStates, miner, miner, Array.Empty <byte>(), new[] { Policy.BlockAction }.ToImmutableList()).First()); }
EvaluateActionsGradually( HashDigest <SHA256> blockHash, long blockIndex, IAccountStateDelta previousStates, Address minerAddress, bool rehearsal = false ) { return(ActionEvaluation.EvaluateActionsGradually( blockHash, blockIndex, previousStates, minerAddress, Signer, Signature, Actions.Cast <IAction>().ToImmutableList(), rehearsal)); }