Example #1
0
        private ValidatorAttendance?GetOrCreateValidatorAttendance(ulong headerIndex)
        {
            var bytes = _validatorAttendanceRepository.LoadState();

            if (bytes is null || bytes.Length == 0)
            {
                return(new ValidatorAttendance(headerIndex / _cycleDuration));
            }
            return(ValidatorAttendance.FromBytes(bytes, headerIndex / _cycleDuration,
                                                 headerIndex % _cycleDuration >= _cycleDuration / 10));
        }
        private ValidatorAttendance?GetValidatorAttendance()
        {
            var bytes = _validatorAttendanceRepository.LoadState();

            if (bytes is null || bytes.Length == 0)
            {
                return(null);
            }
            var cycle        = _stateManager.LastApprovedSnapshot.Blocks.GetTotalBlockHeight() / StakingContract.CycleDuration;
            var indexInCycle = _stateManager.CurrentSnapshot.Blocks.GetTotalBlockHeight() %
                               StakingContract.CycleDuration;

            return(ValidatorAttendance.FromBytes(bytes, cycle,
                                                 indexInCycle >= StakingContract.AttendanceDetectionDuration));
        }