mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 20:07:17 +00:00
5569a68452
* Value assigned to a variable is never read before being overwritten * The result of append is not used anywhere * Suspicious assignment of range-loop vars detected * Unused method receiver detected * Revert "Auxiliary commit to revert individual files from 54edcb445484a2e5d79612e19af8e949b8861253" This reverts commit bbd1e1beabf7b0c5cfc4f514dcc820062ad6c063. * Method modifies receiver * Fix test * Duplicate imports detected * Incorrectly formatted error string * Types of function parameters can be combined * One more "Unused method receiver detected" * Unused parameter detected in function
62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/container/slice"
|
|
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/time/slots"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (s *Service) committeeIndexBeaconAttestationSubscriber(_ context.Context, msg proto.Message) error {
|
|
a, ok := msg.(*eth.Attestation)
|
|
if !ok {
|
|
return fmt.Errorf("message was not type *eth.Attestation, type=%T", msg)
|
|
}
|
|
|
|
if a.Data == nil {
|
|
return errors.New("nil attestation")
|
|
}
|
|
s.setSeenCommitteeIndicesSlot(a.Data.Slot, a.Data.CommitteeIndex, a.AggregationBits)
|
|
|
|
exists, err := s.cfg.attPool.HasAggregatedAttestation(a)
|
|
if err != nil {
|
|
return errors.Wrap(err, "Could not determine if attestation pool has this atttestation")
|
|
}
|
|
if exists {
|
|
return nil
|
|
}
|
|
|
|
return s.cfg.attPool.SaveUnaggregatedAttestation(a)
|
|
}
|
|
|
|
func (_ *Service) persistentSubnetIndices() []uint64 {
|
|
return cache.SubnetIDs.GetAllSubnets()
|
|
}
|
|
|
|
func (_ *Service) aggregatorSubnetIndices(currentSlot types.Slot) []uint64 {
|
|
endEpoch := slots.ToEpoch(currentSlot) + 1
|
|
endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch))
|
|
var commIds []uint64
|
|
for i := currentSlot; i <= endSlot; i++ {
|
|
commIds = append(commIds, cache.SubnetIDs.GetAggregatorSubnetIDs(i)...)
|
|
}
|
|
return slice.SetUint64(commIds)
|
|
}
|
|
|
|
func (_ *Service) attesterSubnetIndices(currentSlot types.Slot) []uint64 {
|
|
endEpoch := slots.ToEpoch(currentSlot) + 1
|
|
endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch))
|
|
var commIds []uint64
|
|
for i := currentSlot; i <= endSlot; i++ {
|
|
commIds = append(commIds, cache.SubnetIDs.GetAttesterSubnetIDs(i)...)
|
|
}
|
|
return slice.SetUint64(commIds)
|
|
}
|