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

            return(clone);
        }
Exemplo n.º 4
0
        public static Eth1Data Clone(Eth1Data other)
        {
            var clone = new Eth1Data(
                Hash32.Clone(other.DepositRoot),
                other.DepositCount,
                Hash32.Clone(other.BlockHash));

            return(clone);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public Crosslink(Shard shard,
                  Hash32 parentRoot,
                  Epoch startEpoch,
                  Epoch endEpoch,
                  Hash32 dataRoot)
 {
     Shard      = shard;
     ParentRoot = parentRoot;
     StartEpoch = startEpoch;
     EndEpoch   = endEpoch;
     DataRoot   = dataRoot;
 }
Exemplo n.º 8
0
 public AttestationData(
     Slot slot,
     CommitteeIndex index,
     Hash32 beaconBlockRoot,
     Checkpoint source,
     Checkpoint target)
 {
     BeaconBlockRoot = beaconBlockRoot;
     Source          = source;
     Target          = target;
     Slot            = slot;
     Index           = index;
 }
Exemplo n.º 9
0
 public BeaconBlockHeader(
     Slot slot,
     Hash32 parentRoot,
     Hash32 stateRoot,
     Hash32 bodyRoot,
     BlsSignature signature)
 {
     Slot       = slot;
     ParentRoot = parentRoot;
     StateRoot  = stateRoot;
     BodyRoot   = bodyRoot;
     Signature  = signature;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 13
0
 public void SetStateRoot(Hash32 stateRoot)
 {
     StateRoot = stateRoot;
 }
Exemplo n.º 14
0
 public Checkpoint(Epoch epoch, Hash32 root)
 {
     Epoch = epoch;
     Root  = root;
 }
Exemplo n.º 15
0
 public void SetRoot(Hash32 root)
 {
     Root = root;
 }
Exemplo n.º 16
0
 public void AddHistoricalRoot(Hash32 historicalRoot) => _historicalRoots.Add(historicalRoot);
Exemplo n.º 17
0
 public Eth1Data(ulong depositCount, Hash32 eth1BlockHash)
     : this(Hash32.Zero, depositCount, eth1BlockHash)
 {
 }
Exemplo n.º 18
0
 public void SetBlockRoot(Slot index, Hash32 blockRoot) => _blockRoots[(int)(ulong)index] = blockRoot;
Exemplo n.º 19
0
 public Eth1Data(Hash32 depositRoot, ulong depositCount, Hash32 blockHash)
 {
     DepositRoot  = depositRoot;
     DepositCount = depositCount;
     BlockHash    = blockHash;
 }
Exemplo n.º 20
0
 public void SetRandaoMix(Epoch randaoIndex, Hash32 mix) => _randaoMixes[(int)(ulong)randaoIndex] = mix;
Exemplo n.º 21
0
 public BeaconBlockHeader(Hash32 bodyRoot)
     : this(Slot.Zero, Hash32.Zero, Hash32.Zero, bodyRoot, new BlsSignature())
 {
 }
Exemplo n.º 22
0
 public void SetStateRoot(Slot index, Hash32 stateRoot) => _stateRoots[(int)(ulong)index] = stateRoot;