Exemple #1
0
        public static int SszLength(BeaconState?container)
        {
            if (container is null)
            {
                return(0);
            }

            int result = SszDynamicOffset;

            result += Hash32.SszLength * (container.HistoricalRoots?.Length ?? 0);
            result += Validator.SszLength * (container.Validators?.Length ?? 0);
            result += Gwei.SszLength * (container.Balances?.Length ?? 0);
            result += Eth1Data.SszLength * (container.Eth1DataVotes?.Length ?? 0);

            result += (container.PreviousEpochAttestations?.Length ?? 0) * sizeof(uint);
            if (!(container.PreviousEpochAttestations is null))
            {
                for (int i = 0; i < container.PreviousEpochAttestations.Length; i++)
                {
                    result += PendingAttestation.SszLength(container.PreviousEpochAttestations[i]);
                }
            }

            result += (container.CurrentEpochAttestations?.Length ?? 0) * sizeof(uint);
            if (!(container.CurrentEpochAttestations is null))
            {
                for (int i = 0; i < container.CurrentEpochAttestations.Length; i++)
                {
                    result += PendingAttestation.SszLength(container.CurrentEpochAttestations[i]);
                }
            }

            return(result);
        }
Exemple #2
0
        public static int SszLength(BeaconState container)
        {
            int result = SszDynamicOffset;

            result += Sha256.SszLength * container.HistoricalRoots.Length;
            result += Validator.SszLength * container.Validators.Length;
            result += Gwei.SszLength * container.Balances.Length;
            result += Eth1Data.SszLength * container.Eth1DataVotes.Length;

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

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

            return(result);
        }