2023-08-18 00:03:31 +00:00
|
|
|
package blockchain
|
|
|
|
|
2023-09-28 21:05:23 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-11-21 18:44:38 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
2023-09-28 21:05:23 +00:00
|
|
|
)
|
|
|
|
|
2023-08-18 00:03:31 +00:00
|
|
|
// SendNewBlobEvent sends a message to the BlobNotifier channel that the blob
|
2023-12-15 04:03:45 +00:00
|
|
|
// for the block root `root` is ready in the database
|
2023-09-28 21:05:23 +00:00
|
|
|
func (s *Service) sendNewBlobEvent(root [32]byte, index uint64) {
|
2023-10-27 03:26:34 +00:00
|
|
|
s.blobNotifiers.notifyIndex(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
|
2023-11-21 18:44:38 +00:00
|
|
|
func (s *Service) ReceiveBlob(ctx context.Context, b blocks.VerifiedROBlob) error {
|
|
|
|
if err := s.blobStorage.Save(b); err != nil {
|
2023-09-28 21:05:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-11-21 18:44:38 +00:00
|
|
|
s.sendNewBlobEvent(b.BlockRoot(), b.Index)
|
2023-09-28 21:05:23 +00:00
|
|
|
return nil
|
|
|
|
}
|