public void ValidateValue(ulong commission) { var len = (Transfers?.Count ?? 0) + (Stakes?.Count ?? 0); var outValue = commission * GasPrice * (ulong)len; if (Transfers != null) { outValue = Transfers.Aggregate(outValue, (current, txOut) => current + txOut.Value); } if (Stakes != null) { outValue = Stakes.Aggregate(outValue, (current, txOut) => current + txOut.Value); } if (Messages != null) { outValue = Messages.Aggregate(outValue, (current, txOut) => current + txOut.Value + txOut.Gas * GasPrice); } var inValue = Inputs.Aggregate((ulong)0, (current, txIn) => current + txIn.Value); if (inValue != outValue) { throw new Exception($"Wrong sum in transaction, inValue: {inValue}, outValue: {outValue}"); } }
private void UpdateData() { var dataValue = (ushort)Inputs .Aggregate(0, (i, vm) => i | (vm.Value ? 1 : 0) << (vm.Number - 1)); _data.WriteRegisters(0, new[] { dataValue }); foreach (var input in Inputs) { _data.WriteCoils(input.Number - 1, new[] { input.Value }); } }
protected override bool Func() { return(Inputs.Aggregate(false, (a, b) => a ^ b[0])); }
protected override bool Func() { return(Inputs.Aggregate(true, (a, b) => a && b[0])); }