public async Task SetExecutionObserverThresholdAsync(IBlockIndex blockIndex, IExecutionObserverThreshold executionObserverThreshold) { if (!ValidateExecutionObserverThreshold(executionObserverThreshold)) { return; } await AddBlockExecutedDataAsync(blockIndex, BranchCountThresholdKey, new Int32Value { Value = executionObserverThreshold.ExecutionBranchThreshold }); await AddBlockExecutedDataAsync(blockIndex, CallCountThresholdKey, new Int32Value { Value = executionObserverThreshold.ExecutionCallThreshold }); Logger.LogDebug( $"ExecutionObserverThreshold has been changed. Branch count threshold is {executionObserverThreshold.ExecutionBranchThreshold}. Call count threshold is {executionObserverThreshold.ExecutionCallThreshold}"); }
private ITransactionContext Create(Transaction transaction, Hash previousBlockHash, long blockHeight, IStateCache stateCache, int callDepth, Timestamp blockTime, IExecutionObserverThreshold executionObserverThreshold) { return(new TransactionContext { Trace = new TransactionTrace { TransactionId = transaction.GetHash() }, Transaction = transaction, PreviousBlockHash = previousBlockHash, BlockHeight = blockHeight, CurrentBlockTime = blockTime ?? TimestampHelper.GetUtcNow(), CallDepth = callDepth, MaxCallDepth = 64, Origin = transaction.From, OriginTransactionId = transaction.GetHash(), ExecutionObserverThreshold = executionObserverThreshold, StateCache = stateCache }); }
private bool ValidateExecutionObserverThreshold(IExecutionObserverThreshold executionObserverThreshold) { return(executionObserverThreshold.ExecutionBranchThreshold > 0 && executionObserverThreshold.ExecutionCallThreshold > 0); }