Пример #1
0
        /// <summary>
        /// Return the beacon proposer index at the current slot.
        /// </summary>
        public ValidatorIndex GetBeaconProposerIndex(BeaconState state)
        {
            Epoch epoch = GetCurrentEpoch(state);

            Span <byte> seedBytes   = stackalloc byte[40];
            Bytes32     initialSeed = GetSeed(state, epoch, _signatureDomainOptions.CurrentValue.BeaconProposer);

            initialSeed.AsSpan().CopyTo(seedBytes);
            BinaryPrimitives.WriteUInt64LittleEndian(seedBytes.Slice(32), state.Slot);
            Bytes32 seed = _cryptographyService.Hash(seedBytes);

            IList <ValidatorIndex> indices       = GetActiveValidatorIndices(state, epoch);
            ValidatorIndex         proposerIndex = _beaconChainUtility.ComputeProposerIndex(state, indices, seed);

            return(proposerIndex);
        }