mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-21 15:29:27 +00:00
eth/catalyst: engine_hasBlobs (#34859)
Co-authored-by: healthykim <bsbs8645@snu.ac.kr> Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
efe58eac00
commit
ef5041ef4d
2 changed files with 13 additions and 12 deletions
|
|
@ -1695,18 +1695,14 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash, version byte) ([]*kzg4844.Blo
|
|||
return blobs, commitments, proofs, nil
|
||||
}
|
||||
|
||||
// AvailableBlobs returns the number of blobs that are available in the subpool.
|
||||
func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int {
|
||||
available := 0
|
||||
for _, vhash := range vhashes {
|
||||
// Retrieve the datastore item (in a short lock)
|
||||
p.lock.RLock()
|
||||
_, exists := p.lookup.storeidOfBlob(vhash)
|
||||
p.lock.RUnlock()
|
||||
if exists {
|
||||
available++
|
||||
}
|
||||
// AvailableBlobs returns whether the blobs are available in the subpool.
|
||||
func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) []bool {
|
||||
available := make([]bool, len(vhashes))
|
||||
p.lock.RLock()
|
||||
for i, vhash := range vhashes {
|
||||
_, available[i] = p.lookup.storeidOfBlob(vhash)
|
||||
}
|
||||
p.lock.RUnlock()
|
||||
return available
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd
|
|||
if len(hashes) > 128 {
|
||||
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)))
|
||||
getBlobsAvailableCounter.Inc(int64(available))
|
||||
|
||||
|
|
@ -679,6 +679,11 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd
|
|||
return res, nil
|
||||
}
|
||||
|
||||
// HasBlobs reports availability for the requested blob-versioned-hashes.
|
||||
func (api *ConsensusAPI) HasBlobs(hashes []common.Hash) []bool {
|
||||
return api.eth.BlobTxPool().AvailableBlobs(hashes)
|
||||
}
|
||||
|
||||
// Helper for NewPayload* methods.
|
||||
var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue