2023-05-18 16:13:18 +00:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed"
|
|
|
|
opfeed "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/operation"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
2023-05-18 16:13:18 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Service) blobSubscriber(ctx context.Context, msg proto.Message) error {
|
2023-11-21 18:44:38 +00:00
|
|
|
b, ok := msg.(blocks.VerifiedROBlob)
|
2023-05-18 16:13:18 +00:00
|
|
|
if !ok {
|
2023-11-21 18:44:38 +00:00
|
|
|
return fmt.Errorf("message was not type blocks.ROBlob, type=%T", msg)
|
2023-05-18 16:13:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-11 00:37:45 +00:00
|
|
|
s.setSeenBlobIndex(b.Slot(), b.ProposerIndex(), b.Index)
|
2023-05-18 16:13:18 +00:00
|
|
|
|
2023-11-21 18:44:38 +00:00
|
|
|
if err := s.cfg.chain.ReceiveBlob(ctx, b); err != nil {
|
2023-08-14 19:18:29 +00:00
|
|
|
return err
|
|
|
|
}
|
2023-05-18 16:13:18 +00:00
|
|
|
|
2023-12-12 15:58:11 +00:00
|
|
|
s.cfg.operationNotifier.OperationFeed().Send(&feed.Event{
|
|
|
|
Type: opfeed.BlobSidecarReceived,
|
|
|
|
Data: &opfeed.BlobSidecarReceivedData{
|
|
|
|
Blob: &b,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2023-05-18 16:13:18 +00:00
|
|
|
return nil
|
|
|
|
}
|