Exemplo n.º 1
0
        public static int AttesterSlashingLength(AttesterSlashing?container)
        {
            if (container is null)
            {
                return(0);
            }

            return(2 * sizeof(uint) +
                   Ssz.IndexedAttestationLength(container.Attestation1) +
                   Ssz.IndexedAttestationLength(container.Attestation2));
        }
Exemplo n.º 2
0
        public static void Encode(Span <byte> span, IndexedAttestation?container)
        {
            if (container is null)
            {
                return;
            }

            if (span.Length != Ssz.IndexedAttestationLength(container))
            {
                ThrowTargetLength <IndexedAttestation>(span.Length, Ssz.IndexedAttestationLength(container));
            }

            int offset        = 0;
            int dynamicOffset = Ssz.IndexedAttestationDynamicOffset;

            Encode(span, container.AttestingIndices.ToArray(), ref offset, ref dynamicOffset);
            Encode(span, container.Data, ref offset);
            Encode(span, container.Signature, ref offset);
        }
Exemplo n.º 3
0
        public static void Encode(Span <byte> span, AttesterSlashing?container)
        {
            if (span.Length != Ssz.AttesterSlashingLength(container))
            {
                ThrowTargetLength <AttesterSlashing>(span.Length, Ssz.AttesterSlashingLength(container));
            }

            if (container == null)
            {
                return;
            }

            int dynamicOffset = 2 * VarOffsetSize;
            int length1       = Ssz.IndexedAttestationLength(container.Attestation1);

            Encode(span.Slice(0, VarOffsetSize), dynamicOffset);
            Encode(span.Slice(dynamicOffset, length1), container.Attestation1);

            dynamicOffset += Ssz.IndexedAttestationLength(container.Attestation1);
            int length2 = Ssz.IndexedAttestationLength(container.Attestation2);

            Encode(span.Slice(VarOffsetSize, VarOffsetSize), dynamicOffset);
            Encode(span.Slice(dynamicOffset, length2), container.Attestation2);
        }