Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions consensus/misc/eip4844/eip4844.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,30 @@ func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
return bcfg.Max
}

// TargetBlobsPerBlock returns the target blobs per block for a block at the given timestamp.
func TargetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
blobConfig := latestBlobConfig(cfg, time)
if blobConfig == nil {
return 0
}
return blobConfig.Target
}

// TargetBlobGasPerBlock returns the target blob gas that can be spent in a block at the given timestamp.
func TargetBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 {
return uint64(TargetBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob
}

// LatestTargetBlobsPerBlock returns the latest target blobs per block defined by the
// configuration, regardless of the currently active fork.
func LatestTargetBlobsPerBlock(cfg *params.ChainConfig) int {
bcfg := latestBlobConfig(cfg, math.MaxUint64)
if bcfg == nil {
return 0
}
return bcfg.Target
}

// fakeExponential approximates factor * e ** (numerator / denominator) using
// Taylor expansion.
func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
Expand Down
Loading