func (s *State) Copy() State {
	newValidatorRegistry := make([]Validator, len(s.ValidatorRegistry))
	for i := range s.ValidatorRegistry {
		newValidatorRegistry[i] = s.ValidatorRegistry[i].Copy()
	}
	newValidatorBalances := make([]uint64, len(s.ValidatorBalances))
	for i := range s.ValidatorBalances {
		newValidatorBalances[i] = s.ValidatorBalances[i]
	}
	newShardRegistry := make([]chainhash.Hash, len(s.ShardRegistry))
	for i := range s.ShardRegistry {
		copy(newShardRegistry[i][:], s.ShardRegistry[i][:])
	}
	newProposals := make([]ActiveProposal, len(s.Proposals))
	for i := range s.Proposals {
		newProposals[i] = s.Proposals[i].Copy()
	}
	newPendingVotes := make([]AggregatedVote, len(s.PendingVotes))
	for i := range s.PendingVotes {
		newPendingVotes[i] = s.PendingVotes[i].Copy()
	}
	var newValidatorRegistryDeltaChainTip chainhash.Hash
	var newRandaoMix chainhash.Hash
	var newNextRandaoMix chainhash.Hash
	copy(newValidatorRegistryDeltaChainTip[:], s.ValidatorRegistryDeltaChainTip[:])
	copy(newRandaoMix[:], s.RandaoMix[:])
	copy(newNextRandaoMix[:], s.NextRandaoMix[:])

	newShardAndCommitteeForSlots := make([][]ShardAndCommittee, len(s.ShardAndCommitteeForSlots))
	for i, slot := range s.ShardAndCommitteeForSlots {
		newShardAndCommitteeForSlots[i] = make([]ShardAndCommittee, len(slot))
		for n, committee := range slot {
			newShardAndCommitteeForSlots[i][n] = committee.Copy()
		}
	}

	newLatestCrosslinks := make([]Crosslink, len(s.LatestCrosslinks))
	copy(newLatestCrosslinks, s.LatestCrosslinks)

	newPreviousCrosslinks := make([]Crosslink, len(s.PreviousCrosslinks))
	copy(newPreviousCrosslinks, s.PreviousCrosslinks)

	newLatestBlockHashes := make([]chainhash.Hash, len(s.LatestBlockHashes))
	copy(newLatestBlockHashes, s.LatestBlockHashes)
	newCurrentAttestations := make([]PendingAttestation, len(s.CurrentEpochAttestations))
	for i := range s.CurrentEpochAttestations {
		newCurrentAttestations[i] = s.CurrentEpochAttestations[i].Copy()
	}

	newPreviousAttestations := make([]PendingAttestation, len(s.PreviousEpochAttestations))
	for i := range s.PreviousEpochAttestations {
		newPreviousAttestations[i] = s.PreviousEpochAttestations[i].Copy()
	}
	newBatchedBlockRoots := make([]chainhash.Hash, len(s.BatchedBlockRoots))
	copy(newBatchedBlockRoots, s.BatchedBlockRoots)
	newState := State{
		Slot:                               s.Slot,
		GenesisTime:                        s.GenesisTime,
		ForkData:                           s.ForkData.Copy(),
		EpochIndex:                         s.EpochIndex,
		ValidatorRegistry:                  newValidatorRegistry,
		ValidatorBalances:                  newValidatorBalances,
		ValidatorRegistryLatestChangeEpoch: s.ValidatorRegistryLatestChangeEpoch,
		ValidatorRegistryExitCount:         s.ValidatorRegistryExitCount,
		ValidatorRegistryDeltaChainTip:     newValidatorRegistryDeltaChainTip,
		RandaoMix:                          newRandaoMix,
		NextRandaoMix:                      newNextRandaoMix,
		ShardAndCommitteeForSlots:          newShardAndCommitteeForSlots,
		PreviousJustifiedEpoch:             s.PreviousJustifiedEpoch,
		JustifiedEpoch:                     s.JustifiedEpoch,
		JustificationBitfield:              s.JustificationBitfield,
		FinalizedEpoch:                     s.FinalizedEpoch,
		LatestCrosslinks:                   newLatestCrosslinks,
		PreviousCrosslinks:                 newPreviousCrosslinks,
		LatestBlockHashes:                  newLatestBlockHashes,
		PreviousEpochAttestations:          newPreviousAttestations,
		CurrentEpochAttestations:           newCurrentAttestations,
		BatchedBlockRoots:                  newBatchedBlockRoots,
		ShardRegistry:                      newShardRegistry,
		PendingVotes:                       newPendingVotes,
		Proposals:                          newProposals,
	}

	return newState
}
// Copy deep-copies the state.
Copy deep-copies the state.
// Copy deep - copies the state .
func (s *State) Copy() State {
	newValidatorRegistry := make([]Validator, len(s.ValidatorRegistry))
	for i := range s.ValidatorRegistry {
		newValidatorRegistry[i] = s.ValidatorRegistry[i].Copy()
	}
	newValidatorBalances := make([]uint64, len(s.ValidatorBalances))
	for i := range s.ValidatorBalances {
		newValidatorBalances[i] = s.ValidatorBalances[i]
	}
	newShardRegistry := make([]chainhash.Hash, len(s.ShardRegistry))
	for i := range s.ShardRegistry {
		copy(newShardRegistry[i][:], s.ShardRegistry[i][:])
	}
	newProposals := make([]ActiveProposal, len(s.Proposals))
	for i := range s.Proposals {
		newProposals[i] = s.Proposals[i].Copy()
	}
	newPendingVotes := make([]AggregatedVote, len(s.PendingVotes))
	for i := range s.PendingVotes {
		newPendingVotes[i] = s.PendingVotes[i].Copy()
	}
	var newValidatorRegistryDeltaChainTip chainhash.Hash
	var newRandaoMix chainhash.Hash
	var newNextRandaoMix chainhash.Hash
	copy(newValidatorRegistryDeltaChainTip[:], s.ValidatorRegistryDeltaChainTip[:])
	copy(newRandaoMix[:], s.RandaoMix[:])
	copy(newNextRandaoMix[:], s.NextRandaoMix[:])
	newShardAndCommitteeForSlots := make([][]ShardAndCommittee, len(s.ShardAndCommitteeForSlots))
	for i, slot := range s.ShardAndCommitteeForSlots {
		newShardAndCommitteeForSlots[i] = make([]ShardAndCommittee, len(slot))
		for n, committee := range slot {
			newShardAndCommitteeForSlots[i][n] = committee.Copy()
		}
	}
	newLatestCrosslinks := make([]Crosslink, len(s.LatestCrosslinks))
	copy(newLatestCrosslinks, s.LatestCrosslinks)
	newPreviousCrosslinks := make([]Crosslink, len(s.PreviousCrosslinks))
	copy(newPreviousCrosslinks, s.PreviousCrosslinks)
	newLatestBlockHashes := make([]chainhash.Hash, len(s.LatestBlockHashes))
	copy(newLatestBlockHashes, s.LatestBlockHashes)
	newCurrentAttestations := make([]PendingAttestation, len(s.CurrentEpochAttestations))
	for i := range s.CurrentEpochAttestations {
		newCurrentAttestations[i] = s.CurrentEpochAttestations[i].Copy()
	}
	newPreviousAttestations := make([]PendingAttestation, len(s.PreviousEpochAttestations))
	for i := range s.PreviousEpochAttestations {
		newPreviousAttestations[i] = s.PreviousEpochAttestations[i].Copy()
	}
	newBatchedBlockRoots := make([]chainhash.Hash, len(s.BatchedBlockRoots))
	copy(newBatchedBlockRoots, s.BatchedBlockRoots)
	newState := State{
		Slot:                               s.Slot,
		GenesisTime:                        s.GenesisTime,
		ForkData:                           s.ForkData.Copy(),
		EpochIndex:                         s.EpochIndex,
		ValidatorRegistry:                  newValidatorRegistry,
		ValidatorBalances:                  newValidatorBalances,
		ValidatorRegistryLatestChangeEpoch: s.ValidatorRegistryLatestChangeEpoch,
		ValidatorRegistryExitCount:         s.ValidatorRegistryExitCount,
		ValidatorRegistryDeltaChainTip:     newValidatorRegistryDeltaChainTip,
		RandaoMix:                          newRandaoMix,
		NextRandaoMix:                      newNextRandaoMix,
		ShardAndCommitteeForSlots:          newShardAndCommitteeForSlots,
		PreviousJustifiedEpoch:             s.PreviousJustifiedEpoch,
		JustifiedEpoch:                     s.JustifiedEpoch,
		JustificationBitfield:              s.JustificationBitfield,
		FinalizedEpoch:                     s.FinalizedEpoch,
		LatestCrosslinks:                   newLatestCrosslinks,
		PreviousCrosslinks:                 newPreviousCrosslinks,
		LatestBlockHashes:                  newLatestBlockHashes,
		PreviousEpochAttestations:          newPreviousAttestations,
		CurrentEpochAttestations:           newCurrentAttestations,
		BatchedBlockRoots:                  newBatchedBlockRoots,
		ShardRegistry:                      newShardRegistry,
		PendingVotes:                       newPendingVotes,
		Proposals:                          newProposals,
	}
	return newState
}
func ( s * State ) Copy ( ) State { newValidatorRegistry := make ( [ ] Validator , len ( s . ValidatorRegistry ) ) for i := range s . ValidatorRegistry { newValidatorRegistry [ i ] = s . ValidatorRegistry [ i ] . Copy ( ) } newValidatorBalances := make ( [ ] uint64 , len ( s . ValidatorBalances ) ) for i := range s . ValidatorBalances { newValidatorBalances [ i ] = s . ValidatorBalances [ i ] } newShardRegistry := make ( [ ] chainhash . Hash , len ( s . ShardRegistry ) ) for i := range s . ShardRegistry { copy ( newShardRegistry [ i ] [ : ] , s . ShardRegistry [ i ] [ : ] ) } newProposals := make ( [ ] ActiveProposal , len ( s . Proposals ) ) for i := range s . Proposals { newProposals [ i ] = s . Proposals [ i ] . Copy ( ) } newPendingVotes := make ( [ ] AggregatedVote , len ( s . PendingVotes ) ) for i := range s . PendingVotes { newPendingVotes [ i ] = s . PendingVotes [ i ] . Copy ( ) } var newValidatorRegistryDeltaChainTip chainhash . Hash var newRandaoMix chainhash . Hash var newNextRandaoMix chainhash . Hash copy ( newValidatorRegistryDeltaChainTip [ : ] , s . ValidatorRegistryDeltaChainTip [ : ] ) copy ( newRandaoMix [ : ] , s . RandaoMix [ : ] ) copy ( newNextRandaoMix [ : ] , s . NextRandaoMix [ : ] ) newShardAndCommitteeForSlots := make ( [ ] [ ] ShardAndCommittee , len ( s . ShardAndCommitteeForSlots ) ) for i , slot := range s . ShardAndCommitteeForSlots { newShardAndCommitteeForSlots [ i ] = make ( [ ] ShardAndCommittee , len ( slot ) ) for n , committee := range slot { newShardAndCommitteeForSlots [ i ] [ n ] = committee . Copy ( ) } } newLatestCrosslinks := make ( [ ] Crosslink , len ( s . LatestCrosslinks ) ) copy ( newLatestCrosslinks , s . LatestCrosslinks ) newPreviousCrosslinks := make ( [ ] Crosslink , len ( s . PreviousCrosslinks ) ) copy ( newPreviousCrosslinks , s . PreviousCrosslinks ) newLatestBlockHashes := make ( [ ] chainhash . Hash , len ( s . LatestBlockHashes ) ) copy ( newLatestBlockHashes , s . LatestBlockHashes ) newCurrentAttestations := make ( [ ] PendingAttestation , len ( s . CurrentEpochAttestations ) ) for i := range s . CurrentEpochAttestations { newCurrentAttestations [ i ] = s . CurrentEpochAttestations [ i ] . Copy ( ) } newPreviousAttestations := make ( [ ] PendingAttestation , len ( s . PreviousEpochAttestations ) ) for i := range s . PreviousEpochAttestations { newPreviousAttestations [ i ] = s . PreviousEpochAttestations [ i ] . Copy ( ) } newBatchedBlockRoots := make ( [ ] chainhash . Hash , len ( s . BatchedBlockRoots ) ) copy ( newBatchedBlockRoots , s . BatchedBlockRoots ) newState := State { Slot : s . Slot , GenesisTime : s . GenesisTime , ForkData : s . ForkData . Copy ( ) , EpochIndex : s . EpochIndex , ValidatorRegistry : newValidatorRegistry , ValidatorBalances : newValidatorBalances , ValidatorRegistryLatestChangeEpoch : s . ValidatorRegistryLatestChangeEpoch , ValidatorRegistryExitCount : s . ValidatorRegistryExitCount , ValidatorRegistryDeltaChainTip : newValidatorRegistryDeltaChainTip , RandaoMix : newRandaoMix , NextRandaoMix : newNextRandaoMix , ShardAndCommitteeForSlots : newShardAndCommitteeForSlots , PreviousJustifiedEpoch : s . PreviousJustifiedEpoch , JustifiedEpoch : s . JustifiedEpoch , JustificationBitfield : s . JustificationBitfield , FinalizedEpoch : s . FinalizedEpoch , LatestCrosslinks : newLatestCrosslinks , PreviousCrosslinks : newPreviousCrosslinks , LatestBlockHashes : newLatestBlockHashes , PreviousEpochAttestations : newPreviousAttestations , CurrentEpochAttestations : newCurrentAttestations , BatchedBlockRoots : newBatchedBlockRoots , ShardRegistry : newShardRegistry , PendingVotes : newPendingVotes , Proposals : newProposals , } return newState }
Copy deep-copies the state.
Copy deep - copies the state .