mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-29 06:37:17 +00:00
41c8ff4c1b
* updates coinciding vars * renames receiver in sync service * Merge branch 'master' into sync-rename-receiver
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package sync
|
||
|
||
import (
|
||
"context"
|
||
"errors"
|
||
"fmt"
|
||
|
||
"github.com/gogo/protobuf/proto"
|
||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed/operation"
|
||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||
)
|
||
|
||
// beaconAggregateProofSubscriber forwards the incoming validated aggregated attestation and proof to the
|
||
// attestation pool for processing.
|
||
func (s *Service) beaconAggregateProofSubscriber(ctx context.Context, msg proto.Message) error {
|
||
a, ok := msg.(*ethpb.SignedAggregateAttestationAndProof)
|
||
if !ok {
|
||
return fmt.Errorf("message was not type *eth.SignedAggregateAttestationAndProof, type=%T", msg)
|
||
}
|
||
|
||
if a.Message.Aggregate == nil || a.Message.Aggregate.Data == nil {
|
||
return errors.New("nil aggregate")
|
||
}
|
||
|
||
// Broadcast the aggregated attestation on a feed to notify other services in the beacon node
|
||
// of a received aggregated attestation.
|
||
s.attestationNotifier.OperationFeed().Send(&feed.Event{
|
||
Type: operation.AggregatedAttReceived,
|
||
Data: &operation.AggregatedAttReceivedData{
|
||
Attestation: a.Message,
|
||
},
|
||
})
|
||
|
||
// An unaggregated attestation can make it here. It’s valid, the aggregator it just itself, although it means poor performance for the subnet.
|
||
if !helpers.IsAggregated(a.Message.Aggregate) {
|
||
return s.attPool.SaveUnaggregatedAttestation(a.Message.Aggregate)
|
||
}
|
||
|
||
return s.attPool.SaveAggregatedAttestation(a.Message.Aggregate)
|
||
}
|