Ejemplo n.º 1
0
 public BeaconBlock(Slot slot, Root parentRoot, Root stateRoot, BeaconBlockBody body)
 {
     Slot       = slot;
     ParentRoot = parentRoot;
     StateRoot  = stateRoot;
     Body       = body;
 }
Ejemplo n.º 2
0
 public BeaconBlock(Hash32 genesisStateRoot)
 {
     Slot       = new Slot(0);
     ParentRoot = Hash32.Zero;
     StateRoot  = genesisStateRoot;
     Body       = new BeaconBlockBody();
     Signature  = BlsSignature.Empty;
 }
Ejemplo n.º 3
0
        public bool Equals(BeaconBlockBody other)
        {
            bool basicEquality = Equals(RandaoReversal, other.RandaoReversal) &&
                                 Equals(Eth1Data, other.Eth1Data) &&
                                 Bytes.AreEqual(Graffiti, other.Graffiti) &&
                                 ProposerSlashings.Length == other.ProposerSlashings.Length &&
                                 AttesterSlashings.Length == other.AttesterSlashings.Length &&
                                 Attestations.Length == other.Attestations.Length &&
                                 Deposits.Length == other.Deposits.Length &&
                                 VoluntaryExits.Length == other.VoluntaryExits.Length;

            if (!basicEquality)
            {
                return(false);
            }

            for (int i = 0; i < AttesterSlashings.Length; i++)
            {
                if (!Equals(AttesterSlashings[i], other.AttesterSlashings[i]))
                {
                    return(false);
                }
            }

            for (int i = 0; i < ProposerSlashings.Length; i++)
            {
                if (!Equals(ProposerSlashings[i], other.ProposerSlashings[i]))
                {
                    return(false);
                }
            }

            for (int i = 0; i < Attestations.Length; i++)
            {
                if (!Equals(Attestations[i], other.Attestations[i]))
                {
                    return(false);
                }
            }

            for (int i = 0; i < Deposits.Length; i++)
            {
                if (!Equals(Deposits[i], other.Deposits[i]))
                {
                    return(false);
                }
            }

            for (int i = 0; i < VoluntaryExits.Length; i++)
            {
                if (!Equals(VoluntaryExits[i], other.VoluntaryExits[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
 public BeaconBlock(Slot slot, Hash32 parentRoot, Hash32 stateRoot, BeaconBlockBody body, BlsSignature signature)
 {
     Slot       = slot;
     ParentRoot = parentRoot;
     StateRoot  = stateRoot;
     Body       = body;
     Signature  = signature;
     //Body = new BeaconBlockBody(randaoReveal,
     //    new Eth1Data(Hash32.Zero, 0),
     //    new Bytes32(), Array.Empty<Deposit>());
 }
Ejemplo n.º 5
0
        public static int SszLength(BeaconBlockBody container)
        {
            int result = SszDynamicOffset;

            result += ProposerSlashing.SszLength * container.ProposerSlashings.Length;
            result += Deposit.SszLength * container.Deposits.Length;
            result += VoluntaryExit.SszLength * container.VoluntaryExits.Length;

            result += sizeof(uint) * container.AttesterSlashings.Length;
            for (int i = 0; i < container.AttesterSlashings.Length; i++)
            {
                result += AttesterSlashing.SszLength(container.AttesterSlashings[i]);
            }

            result += sizeof(uint) * container.Attestations.Length;
            for (int i = 0; i < container.Attestations.Length; i++)
            {
                result += Attestation.SszLength(container.Attestations[i]);
            }

            return(result);
        }
Ejemplo n.º 6
0
 public static int SszLength(BeaconBlock?container)
 {
     return(container is null ? 0 : (SszDynamicOffset + BeaconBlockBody.SszLength(container.Body)));
 }