func (s *State) applyCasperSlashing(casperSlashing CasperSlashing, c *config.Config) error {
	var intersection []uint32
	indices1 := indices(casperSlashing.Votes1)
	indices2 := indices(casperSlashing.Votes2)
	for _, k := range indices1 {
		for _, m := range indices2 {
			if k == m {
				intersection = append(intersection, k)
			}
		}
	}

	if len(intersection) == 0 {
		return errors.New("casper slashing does not include intersection")
	}

	if casperSlashing.Votes1.Data.Equals(&casperSlashing.Votes2.Data) {
		return errors.New("casper slashing votes are the same")
	}

	if !isDoubleVote(casperSlashing.Votes1.Data, casperSlashing.Votes2.Data) &&
		!isSurroundVote(casperSlashing.Votes1.Data, casperSlashing.Votes2.Data) {
		return errors.New("casper slashing is not double or surround vote")
	}

	if !s.verifySlashableVoteData(casperSlashing.Votes1, c) {
		return errors.New("casper slashing signature did not verify")
	}

	if !s.verifySlashableVoteData(casperSlashing.Votes2, c) {
		return errors.New("casper slashing signature did not verify")
	}

	for _, i := range intersection {
		if s.ValidatorRegistry[i].Status != ExitedWithPenalty {
			err := s.UpdateValidatorStatus(i, ExitedWithPenalty, c)
			if err != nil {
				return err
			}
		}
	}

	return nil
}
// applyCasperSlashing applies a casper slashing claim to the current state.
applyCasperSlashing applies a casper slashing claim to the current state.
// applyCasperSlashing applies a casper slashing claim to the current state .
func (s *State) applyCasperSlashing(casperSlashing CasperSlashing, c *config.Config) error {
	var intersection []uint32
	indices1 := indices(casperSlashing.Votes1)
	indices2 := indices(casperSlashing.Votes2)
	for _, k := range indices1 {
		for _, m := range indices2 {
			if k == m {
				intersection = append(intersection, k)
			}
		}
	}
	if len(intersection) == 0 {
		return errors.New("casper slashing does not include intersection")
	}
	if casperSlashing.Votes1.Data.Equals(&casperSlashing.Votes2.Data) {
		return errors.New("casper slashing votes are the same")
	}
	if !isDoubleVote(casperSlashing.Votes1.Data, casperSlashing.Votes2.Data) &&
		!isSurroundVote(casperSlashing.Votes1.Data, casperSlashing.Votes2.Data) {
		return errors.New("casper slashing is not double or surround vote")
	}
	if !s.verifySlashableVoteData(casperSlashing.Votes1, c) {
		return errors.New("casper slashing signature did not verify")
	}
	if !s.verifySlashableVoteData(casperSlashing.Votes2, c) {
		return errors.New("casper slashing signature did not verify")
	}
	for _, i := range intersection {
		if s.ValidatorRegistry[i].Status != ExitedWithPenalty {
			err := s.UpdateValidatorStatus(i, ExitedWithPenalty, c)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
func ( s * State ) applyCasperSlashing ( casperSlashing CasperSlashing , c * config . Config ) error { var intersection [ ] uint32 indices1 := indices ( casperSlashing . Votes1 ) indices2 := indices ( casperSlashing . Votes2 ) for _ , k := range indices1 { for _ , m := range indices2 { if k == m { intersection = append ( intersection , k ) } } } if len ( intersection ) == 0 { return errors . New ( " " ) } if casperSlashing . Votes1 . Data . Equals ( & casperSlashing . Votes2 . Data ) { return errors . New ( " " ) } if ! isDoubleVote ( casperSlashing . Votes1 . Data , casperSlashing . Votes2 . Data ) && ! isSurroundVote ( casperSlashing . Votes1 . Data , casperSlashing . Votes2 . Data ) { return errors . New ( " " ) } if ! s . verifySlashableVoteData ( casperSlashing . Votes1 , c ) { return errors . New ( " " ) } if ! s . verifySlashableVoteData ( casperSlashing . Votes2 , c ) { return errors . New ( " " ) } for _ , i := range intersection { if s . ValidatorRegistry [ i ] . Status != ExitedWithPenalty { err := s . UpdateValidatorStatus ( i , ExitedWithPenalty , c ) if err != nil { return err } } } return nil }
applyCasperSlashing applies a casper slashing claim to the current state.
applyCasperSlashing applies a casper slashing claim to the current state .