Пример #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);
        }
Пример #2
0
 public void SetDepositRoot(Hash32 depositRoot)
 {
     if (depositRoot == null)
     {
         throw new ArgumentNullException(nameof(depositRoot));
     }
     DepositRoot = depositRoot;
 }
Пример #3
0
        public static Checkpoint Clone(Checkpoint other)
        {
            var clone = new Checkpoint(
                other.Epoch,
                Hash32.Clone(other.Root));

            return(clone);
        }
Пример #4
0
        public static Eth1Data Clone(Eth1Data other)
        {
            var clone = new Eth1Data(
                Hash32.Clone(other.DepositRoot),
                other.DepositCount,
                Hash32.Clone(other.BlockHash));

            return(clone);
        }
Пример #5
0
        public static AttestationData Clone(AttestationData other)
        {
            var clone = new AttestationData(
                other.Slot,
                other.Index,
                Hash32.Clone(other.BeaconBlockRoot),
                Checkpoint.Clone(other.Source),
                Checkpoint.Clone(other.Target)
                );

            return(clone);
        }
Пример #6
0
        /// <summary>
        /// Creates a deep copy of the object.
        /// </summary>
        public static Crosslink Clone(Crosslink other)
        {
            var clone = new Crosslink(
                other.Shard,
                Hash32.Clone(other.ParentRoot),
                other.StartEpoch,
                other.EndEpoch,
                Hash32.Clone(other.DataRoot)
                );

            return(clone);
        }
Пример #7
0
 public Crosslink(Shard shard,
                  Hash32 parentRoot,
                  Epoch startEpoch,
                  Epoch endEpoch,
                  Hash32 dataRoot)
 {
     Shard      = shard;
     ParentRoot = parentRoot;
     StartEpoch = startEpoch;
     EndEpoch   = endEpoch;
     DataRoot   = dataRoot;
 }
Пример #8
0
 public AttestationData(
     Slot slot,
     CommitteeIndex index,
     Hash32 beaconBlockRoot,
     Checkpoint source,
     Checkpoint target)
 {
     BeaconBlockRoot = beaconBlockRoot;
     Source          = source;
     Target          = target;
     Slot            = slot;
     Index           = index;
 }
Пример #9
0
 public BeaconBlockHeader(
     Slot slot,
     Hash32 parentRoot,
     Hash32 stateRoot,
     Hash32 bodyRoot,
     BlsSignature signature)
 {
     Slot       = slot;
     ParentRoot = parentRoot;
     StateRoot  = stateRoot;
     BodyRoot   = bodyRoot;
     Signature  = signature;
 }
Пример #10
0
        /// <summary>
        /// Creates a deep copy of the object.
        /// </summary>
        public static BeaconBlockHeader Clone(BeaconBlockHeader other)
        {
            var clone = new BeaconBlockHeader(Hash32.Clone(other.BodyRoot))
            {
                Slot       = other.Slot,
                ParentRoot = Hash32.Clone(other.ParentRoot),
                StateRoot  = Hash32.Clone(other.StateRoot),
                BodyRoot   = Hash32.Clone(other.BodyRoot),
                Signature  = BlsSignature.Clone(other.Signature)
            };

            return(clone);
        }
Пример #11
0
        public static Validator Clone(Validator other)
        {
            var clone = new Validator(
                BlsPublicKey.Clone(other.PublicKey),
                Hash32.Clone(other.WithdrawalCredentials),
                other.EffectiveBalance,
                other.ActivationEligibilityEpoch,
                other.ActivationEpoch,
                other.ExitEpoch,
                other.WithdrawableEpoch
                );

            return(clone);
        }
Пример #12
0
 public Validator(
     BlsPublicKey publicKey,
     Hash32 withdrawalCredentials,
     Gwei effectiveBalance,
     //bool slashed,
     Epoch activationEligibilityEpoch,
     Epoch activationEpoch,
     Epoch exitEpoch,
     Epoch withdrawableEpoch)
 {
     PublicKey                  = publicKey;
     WithdrawalCredentials      = withdrawalCredentials;
     EffectiveBalance           = effectiveBalance;
     ActivationEligibilityEpoch = activationEligibilityEpoch;
     ActivationEpoch            = activationEpoch;
     ExitEpoch                  = exitEpoch;
     WithdrawableEpoch          = withdrawableEpoch;
 }
Пример #13
0
 public void SetStateRoot(Hash32 stateRoot)
 {
     StateRoot = stateRoot;
 }
Пример #14
0
 public Checkpoint(Epoch epoch, Hash32 root)
 {
     Epoch = epoch;
     Root  = root;
 }
Пример #15
0
 public void SetRoot(Hash32 root)
 {
     Root = root;
 }
Пример #16
0
 public void AddHistoricalRoot(Hash32 historicalRoot) => _historicalRoots.Add(historicalRoot);
Пример #17
0
 public Eth1Data(ulong depositCount, Hash32 eth1BlockHash)
     : this(Hash32.Zero, depositCount, eth1BlockHash)
 {
 }
Пример #18
0
 public void SetBlockRoot(Slot index, Hash32 blockRoot) => _blockRoots[(int)(ulong)index] = blockRoot;
Пример #19
0
 public Eth1Data(Hash32 depositRoot, ulong depositCount, Hash32 blockHash)
 {
     DepositRoot  = depositRoot;
     DepositCount = depositCount;
     BlockHash    = blockHash;
 }
Пример #20
0
 public void SetRandaoMix(Epoch randaoIndex, Hash32 mix) => _randaoMixes[(int)(ulong)randaoIndex] = mix;
Пример #21
0
 public BeaconBlockHeader(Hash32 bodyRoot)
     : this(Slot.Zero, Hash32.Zero, Hash32.Zero, bodyRoot, new BlsSignature())
 {
 }
Пример #22
0
 public void SetStateRoot(Slot index, Hash32 stateRoot) => _stateRoots[(int)(ulong)index] = stateRoot;