2023-08-18 00:03:31 +00:00
|
|
|
package blockchain
|
|
|
|
|
2023-09-28 21:05:23 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
|
|
)
|
|
|
|
|
2023-08-18 00:03:31 +00:00
|
|
|
// SendNewBlobEvent sends a message to the BlobNotifier channel that the blob
|
|
|
|
// for the blocroot `root` is ready in the database
|
2023-09-28 21:05:23 +00:00
|
|
|
func (s *Service) sendNewBlobEvent(root [32]byte, index uint64) {
|
2023-09-12 15:32:21 +00:00
|
|
|
s.blobNotifiers.forRoot(root) <- index
|
2023-08-18 00:03:31 +00:00
|
|
|
}
|
2023-09-28 21:05:23 +00:00
|
|
|
|
|
|
|
// ReceiveBlob saves the blob to database and sends the new event
|
|
|
|
func (s *Service) ReceiveBlob(ctx context.Context, b *ethpb.BlobSidecar) error {
|
|
|
|
if err := s.cfg.BeaconDB.SaveBlobSidecar(ctx, []*ethpb.BlobSidecar{b}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
s.sendNewBlobEvent([32]byte(b.BlockRoot), b.Index)
|
|
|
|
return nil
|
|
|
|
}
|