core/catalyst: engine_hasBlobs

This commit is contained in:
MariusVanDerWijden 2026-04-30 18:52:23 +02:00
parent efe58eac00
commit 00a0657a15
No known key found for this signature in database
2 changed files with 9 additions and 5 deletions

View file

@ -1696,15 +1696,15 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash, version byte) ([]*kzg4844.Blo
} }
// AvailableBlobs returns the number of blobs that are available in the subpool. // AvailableBlobs returns the number of blobs that are available in the subpool.
func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int { func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) []bool {
available := 0 available := make([]bool, len(vhashes))
for _, vhash := range vhashes { for i, vhash := range vhashes {
// Retrieve the datastore item (in a short lock) // Retrieve the datastore item (in a short lock)
p.lock.RLock() p.lock.RLock()
_, exists := p.lookup.storeidOfBlob(vhash) _, exists := p.lookup.storeidOfBlob(vhash)
p.lock.RUnlock() p.lock.RUnlock()
if exists { if exists {
available++ available[i] = true
} }
} }
return available return available

View file

@ -630,7 +630,7 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd
if len(hashes) > 128 { if len(hashes) > 128 {
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
} }
available := api.eth.BlobTxPool().AvailableBlobs(hashes) available := len(api.eth.BlobTxPool().AvailableBlobs(hashes))
getBlobsRequestedCounter.Inc(int64(len(hashes))) getBlobsRequestedCounter.Inc(int64(len(hashes)))
getBlobsAvailableCounter.Inc(int64(available)) getBlobsAvailableCounter.Inc(int64(available))
@ -679,6 +679,10 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd
return res, nil return res, nil
} }
func (api *ConsensusAPI) HasBlobs(hashes []common.Hash) ([]bool, error) {
return api.eth.BlobTxPool().AvailableBlobs(hashes), nil
}
// Helper for NewPayload* methods. // Helper for NewPayload* methods.
var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID} var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}