Beispiel #1
0
        /// <summary>
        /// Creates a deep copy of the object.
        /// </summary>
        public static BeaconState Clone(BeaconState other)
        {
            var clone = new BeaconState(
                other.GenesisTime,
                other.Slot,
                Fork.Clone(other.Fork),
                BeaconBlockHeader.Clone(other.LatestBlockHeader),
                other.BlockRoots.Select(x => Hash32.Clone(x)).ToArray(),
                other.StateRoots.Select(x => Hash32.Clone(x)).ToArray(),
                other.HistoricalRoots.Select(x => Hash32.Clone(x)).ToList(),
                Eth1Data.Clone(other.Eth1Data),
                other.Eth1DataVotes.Select(x => Eth1Data.Clone(x)).ToList(),
                other.Eth1DepositIndex,
                other.Validators.Select(x => Validator.Clone(x)).ToList(),
                other.Balances.Select(x => x).ToList(),
                other.RandaoMixes.Select(x => Hash32.Clone(x)).ToArray(),
                other.Slashings.Select(x => x).ToArray(),
                other.PreviousEpochAttestations.Select(x => PendingAttestation.Clone(x)).ToList(),
                other.CurrentEpochAttestations.Select(x => PendingAttestation.Clone(x)).ToList(),
                new BitArray(other.JustificationBits),
                Checkpoint.Clone(other.PreviousJustifiedCheckpoint),
                Checkpoint.Clone(other.CurrentJustifiedCheckpoint),
                Checkpoint.Clone(other.FinalizedCheckpoint)
                );

            return(clone);
        }
Beispiel #2
0
        public static PendingAttestation Clone(PendingAttestation other)
        {
            var clone = new PendingAttestation(
                new BitArray(other.AggregationBits),
                AttestationData.Clone(other.Data),
                other.InclusionDelay,
                other.ProposerIndex);

            return(clone);
        }
Beispiel #3
0
 public void AddPreviousAttestation(PendingAttestation attestation) => _previousEpochAttestations.Add(attestation);
Beispiel #4
0
 public void AddCurrentAttestation(PendingAttestation attestation) => _currentEpochAttestations.Add(attestation);