func (s *State) ToProto() *pb.State {
	validatorRegistry := make([]*pb.Validator, len(s.ValidatorRegistry))
	shardCommittees := make([]*pb.ShardCommitteesForSlot, len(s.ShardAndCommitteeForSlots))
	latestCrosslinks := make([]*pb.Crosslink, len(s.LatestCrosslinks))
	previousCrosslinks := make([]*pb.Crosslink, len(s.PreviousCrosslinks))
	latestBlockHashes := make([][]byte, len(s.LatestBlockHashes))
	currentAttestations := make([]*pb.PendingAttestation, len(s.CurrentEpochAttestations))
	previousAttestations := make([]*pb.PendingAttestation, len(s.PreviousEpochAttestations))
	batchedBlockRoots := make([][]byte, len(s.BatchedBlockRoots))
	proposals := make([]*pb.ActiveProposal, len(s.Proposals))
	shardRegistry := make([][]byte, len(s.ShardRegistry))
	pendingVotes := make([]*pb.AggregatedVote, len(s.PendingVotes))

	for i := range validatorRegistry {
		validatorRegistry[i] = s.ValidatorRegistry[i].ToProto()
	}

	for i := range shardCommittees {
		committees := make([]*pb.ShardCommittee, len(s.ShardAndCommitteeForSlots[i]))
		for j := range committees {
			committees[j] = s.ShardAndCommitteeForSlots[i][j].ToProto()
		}

		shardCommittees[i] = &pb.ShardCommitteesForSlot{
			Committees: committees,
		}
	}

	for i := range latestCrosslinks {
		latestCrosslinks[i] = s.LatestCrosslinks[i].ToProto()
	}

	for i := range previousCrosslinks {
		previousCrosslinks[i] = s.PreviousCrosslinks[i].ToProto()
	}

	for i := range latestBlockHashes {
		latestBlockHashes[i] = s.LatestBlockHashes[i][:]
	}

	for i := range currentAttestations {
		currentAttestations[i] = s.CurrentEpochAttestations[i].ToProto()
	}

	for i := range previousAttestations {
		previousAttestations[i] = s.PreviousEpochAttestations[i].ToProto()
	}

	for i := range proposals {
		proposals[i] = s.Proposals[i].ToProto()
	}

	for i := range pendingVotes {
		pendingVotes[i] = s.PendingVotes[i].ToProto()
	}

	for i := range shardRegistry {
		shardRegistry[i] = s.ShardRegistry[i][:]
	}

	for i := range batchedBlockRoots {
		batchedBlockRoots[i] = s.BatchedBlockRoots[i][:]
	}

	return &pb.State{
		Slot:                               s.Slot,
		GenesisTime:                        s.GenesisTime,
		EpochIndex:                         s.EpochIndex,
		ForkData:                           s.ForkData.ToProto(),
		ValidatorRegistry:                  validatorRegistry,
		ValidatorBalances:                  s.ValidatorBalances,
		ValidatorRegistryLatestChangeEpoch: s.ValidatorRegistryLatestChangeEpoch,
		ValidatorRegistryDeltaChainTip:     s.ValidatorRegistryDeltaChainTip[:],
		ValidatorRegistryExitCount:         s.ValidatorRegistryExitCount,
		RandaoMix:                          s.RandaoMix[:],
		NextRandaoMix:                      s.NextRandaoMix[:],
		ShardCommittees:                    shardCommittees,
		PreviousJustifiedEpoch:             s.PreviousJustifiedEpoch,
		JustifiedEpoch:                     s.JustifiedEpoch,
		JustificationBitField:              s.JustificationBitfield,
		FinalizedEpoch:                     s.FinalizedEpoch,
		LatestCrosslinks:                   latestCrosslinks,
		PreviousCrosslinks:                 previousCrosslinks,
		LatestBlockHashes:                  latestBlockHashes,
		CurrentEpochAttestations:           currentAttestations,
		PreviousEpochAttestations:          previousAttestations,
		BatchedBlockRoots:                  batchedBlockRoots,
		ShardRegistry:                      shardRegistry,
		PendingVotes:                       pendingVotes,
		Proposals:                          proposals,
	}
}
// ToProto gets the protobuf representation of the state.
ToProto gets the protobuf representation of the state.
// ToProto gets the protobuf representation of the state .
func (s *State) ToProto() *pb.State {
	validatorRegistry := make([]*pb.Validator, len(s.ValidatorRegistry))
	shardCommittees := make([]*pb.ShardCommitteesForSlot, len(s.ShardAndCommitteeForSlots))
	latestCrosslinks := make([]*pb.Crosslink, len(s.LatestCrosslinks))
	previousCrosslinks := make([]*pb.Crosslink, len(s.PreviousCrosslinks))
	latestBlockHashes := make([][]byte, len(s.LatestBlockHashes))
	currentAttestations := make([]*pb.PendingAttestation, len(s.CurrentEpochAttestations))
	previousAttestations := make([]*pb.PendingAttestation, len(s.PreviousEpochAttestations))
	batchedBlockRoots := make([][]byte, len(s.BatchedBlockRoots))
	proposals := make([]*pb.ActiveProposal, len(s.Proposals))
	shardRegistry := make([][]byte, len(s.ShardRegistry))
	pendingVotes := make([]*pb.AggregatedVote, len(s.PendingVotes))
	for i := range validatorRegistry {
		validatorRegistry[i] = s.ValidatorRegistry[i].ToProto()
	}
	for i := range shardCommittees {
		committees := make([]*pb.ShardCommittee, len(s.ShardAndCommitteeForSlots[i]))
		for j := range committees {
			committees[j] = s.ShardAndCommitteeForSlots[i][j].ToProto()
		}
		shardCommittees[i] = &pb.ShardCommitteesForSlot{
			Committees: committees,
		}
	}
	for i := range latestCrosslinks {
		latestCrosslinks[i] = s.LatestCrosslinks[i].ToProto()
	}
	for i := range previousCrosslinks {
		previousCrosslinks[i] = s.PreviousCrosslinks[i].ToProto()
	}
	for i := range latestBlockHashes {
		latestBlockHashes[i] = s.LatestBlockHashes[i][:]
	}
	for i := range currentAttestations {
		currentAttestations[i] = s.CurrentEpochAttestations[i].ToProto()
	}
	for i := range previousAttestations {
		previousAttestations[i] = s.PreviousEpochAttestations[i].ToProto()
	}
	for i := range proposals {
		proposals[i] = s.Proposals[i].ToProto()
	}
	for i := range pendingVotes {
		pendingVotes[i] = s.PendingVotes[i].ToProto()
	}
	for i := range shardRegistry {
		shardRegistry[i] = s.ShardRegistry[i][:]
	}
	for i := range batchedBlockRoots {
		batchedBlockRoots[i] = s.BatchedBlockRoots[i][:]
	}
	return &pb.State{
		Slot:                               s.Slot,
		GenesisTime:                        s.GenesisTime,
		EpochIndex:                         s.EpochIndex,
		ForkData:                           s.ForkData.ToProto(),
		ValidatorRegistry:                  validatorRegistry,
		ValidatorBalances:                  s.ValidatorBalances,
		ValidatorRegistryLatestChangeEpoch: s.ValidatorRegistryLatestChangeEpoch,
		ValidatorRegistryDeltaChainTip:     s.ValidatorRegistryDeltaChainTip[:],
		ValidatorRegistryExitCount:         s.ValidatorRegistryExitCount,
		RandaoMix:                          s.RandaoMix[:],
		NextRandaoMix:                      s.NextRandaoMix[:],
		ShardCommittees:                    shardCommittees,
		PreviousJustifiedEpoch:             s.PreviousJustifiedEpoch,
		JustifiedEpoch:                     s.JustifiedEpoch,
		JustificationBitField:              s.JustificationBitfield,
		FinalizedEpoch:                     s.FinalizedEpoch,
		LatestCrosslinks:                   latestCrosslinks,
		PreviousCrosslinks:                 previousCrosslinks,
		LatestBlockHashes:                  latestBlockHashes,
		CurrentEpochAttestations:           currentAttestations,
		PreviousEpochAttestations:          previousAttestations,
		BatchedBlockRoots:                  batchedBlockRoots,
		ShardRegistry:                      shardRegistry,
		PendingVotes:                       pendingVotes,
		Proposals:                          proposals,
	}
}
func ( s * State ) ToProto ( ) * pb . State { validatorRegistry := make ( [ ] * pb . Validator , len ( s . ValidatorRegistry ) ) shardCommittees := make ( [ ] * pb . ShardCommitteesForSlot , len ( s . ShardAndCommitteeForSlots ) ) latestCrosslinks := make ( [ ] * pb . Crosslink , len ( s . LatestCrosslinks ) ) previousCrosslinks := make ( [ ] * pb . Crosslink , len ( s . PreviousCrosslinks ) ) latestBlockHashes := make ( [ ] [ ] byte , len ( s . LatestBlockHashes ) ) currentAttestations := make ( [ ] * pb . PendingAttestation , len ( s . CurrentEpochAttestations ) ) previousAttestations := make ( [ ] * pb . PendingAttestation , len ( s . PreviousEpochAttestations ) ) batchedBlockRoots := make ( [ ] [ ] byte , len ( s . BatchedBlockRoots ) ) proposals := make ( [ ] * pb . ActiveProposal , len ( s . Proposals ) ) shardRegistry := make ( [ ] [ ] byte , len ( s . ShardRegistry ) ) pendingVotes := make ( [ ] * pb . AggregatedVote , len ( s . PendingVotes ) ) for i := range validatorRegistry { validatorRegistry [ i ] = s . ValidatorRegistry [ i ] . ToProto ( ) } for i := range shardCommittees { committees := make ( [ ] * pb . ShardCommittee , len ( s . ShardAndCommitteeForSlots [ i ] ) ) for j := range committees { committees [ j ] = s . ShardAndCommitteeForSlots [ i ] [ j ] . ToProto ( ) } shardCommittees [ i ] = & pb . ShardCommitteesForSlot { Committees : committees , } } for i := range latestCrosslinks { latestCrosslinks [ i ] = s . LatestCrosslinks [ i ] . ToProto ( ) } for i := range previousCrosslinks { previousCrosslinks [ i ] = s . PreviousCrosslinks [ i ] . ToProto ( ) } for i := range latestBlockHashes { latestBlockHashes [ i ] = s . LatestBlockHashes [ i ] [ : ] } for i := range currentAttestations { currentAttestations [ i ] = s . CurrentEpochAttestations [ i ] . ToProto ( ) } for i := range previousAttestations { previousAttestations [ i ] = s . PreviousEpochAttestations [ i ] . ToProto ( ) } for i := range proposals { proposals [ i ] = s . Proposals [ i ] . ToProto ( ) } for i := range pendingVotes { pendingVotes [ i ] = s . PendingVotes [ i ] . ToProto ( ) } for i := range shardRegistry { shardRegistry [ i ] = s . ShardRegistry [ i ] [ : ] } for i := range batchedBlockRoots { batchedBlockRoots [ i ] = s . BatchedBlockRoots [ i ] [ : ] } return & pb . State { Slot : s . Slot , GenesisTime : s . GenesisTime , EpochIndex : s . EpochIndex , ForkData : s . ForkData . ToProto ( ) , ValidatorRegistry : validatorRegistry , ValidatorBalances : s . ValidatorBalances , ValidatorRegistryLatestChangeEpoch : s . ValidatorRegistryLatestChangeEpoch , ValidatorRegistryDeltaChainTip : s . ValidatorRegistryDeltaChainTip [ : ] , ValidatorRegistryExitCount : s . ValidatorRegistryExitCount , RandaoMix : s . RandaoMix [ : ] , NextRandaoMix : s . NextRandaoMix [ : ] , ShardCommittees : shardCommittees , PreviousJustifiedEpoch : s . PreviousJustifiedEpoch , JustifiedEpoch : s . JustifiedEpoch , JustificationBitField : s . JustificationBitfield , FinalizedEpoch : s . FinalizedEpoch , LatestCrosslinks : latestCrosslinks , PreviousCrosslinks : previousCrosslinks , LatestBlockHashes : latestBlockHashes , CurrentEpochAttestations : currentAttestations , PreviousEpochAttestations : previousAttestations , BatchedBlockRoots : batchedBlockRoots , ShardRegistry : shardRegistry , PendingVotes : pendingVotes , Proposals : proposals , } }
ToProto gets the protobuf representation of the state.
ToProto gets the protobuf representation of the state .