mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-22 07:49:26 +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
|
return blobs, commitments, proofs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvailableBlobs returns the number of blobs that are available in the subpool.
|
// AvailableBlobs returns whether the blobs 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 {
|
p.lock.RLock()
|
||||||
// Retrieve the datastore item (in a short lock)
|
for i, vhash := range vhashes {
|
||||||
p.lock.RLock()
|
_, available[i] = p.lookup.storeidOfBlob(vhash)
|
||||||
_, exists := p.lookup.storeidOfBlob(vhash)
|
|
||||||
p.lock.RUnlock()
|
|
||||||
if exists {
|
|
||||||
available++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
p.lock.RUnlock()
|
||||||
return available
|
return available
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,11 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd
|
||||||
return res, nil
|
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.
|
// Helper for NewPayload* methods.
|
||||||
var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}
|
var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue