public BeaconBlock(Slot slot, Root parentRoot, Root stateRoot, BeaconBlockBody body) { Slot = slot; ParentRoot = parentRoot; StateRoot = stateRoot; Body = body; }
public BeaconBlock(Hash32 genesisStateRoot) { Slot = new Slot(0); ParentRoot = Hash32.Zero; StateRoot = genesisStateRoot; Body = new BeaconBlockBody(); Signature = BlsSignature.Empty; }
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); }
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>()); }
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); }
public static int SszLength(BeaconBlock?container) { return(container is null ? 0 : (SszDynamicOffset + BeaconBlockBody.SszLength(container.Body))); }