Пример #1
0
        private void SubmitAttendanceDetection()
        {
            Logger.LogInformation("SubmitAttendanceDetection");
            var previousValidators = _systemContractReader.GetPreviousValidators();

            var publicKeys     = new byte[previousValidators.Length][];
            var attendances    = new UInt256[previousValidators.Length];
            var attendanceData = GetValidatorAttendance();

            if (attendanceData == null)
            {
                Logger.LogWarning("Attendance detection data didn't collected");
                return;
            }

            for (var i = 0; i < previousValidators.Length; i++)
            {
                var publicKey     = previousValidators[i];
                var previousCycle = _stateManager.LastApprovedSnapshot.Blocks.GetTotalBlockHeight() /
                                    StakingContract.CycleDuration - 1;
                attendances[i] = new BigInteger(attendanceData.GetAttendanceForCycle(publicKey, previousCycle))
                                 .ToUInt256();
                publicKeys[i] = publicKey;
            }

            var tx = _transactionBuilder.InvokeTransaction(
                _systemContractReader.NodeAddress(),
                ContractRegisterer.StakingContract,
                Money.Zero,
                StakingInterface.MethodSubmitAttendanceDetection,
                publicKeys,
                attendances
                );

            _validatorAttendanceRepository.SaveState(attendanceData.ToBytes());
            AddTxToPool(tx);
        }