mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 16:59:26 +00:00
interface for public api
This commit is contained in:
parent
35d19278e7
commit
b9999244e5
5 changed files with 11 additions and 11 deletions
|
|
@ -324,7 +324,7 @@ type BlockChain struct {
|
|||
flushInterval atomic.Int64 // Time interval (processing time) after which to flush a state
|
||||
triedb *triedb.Database // The database handler for maintaining trie nodes.
|
||||
codedb *state.CodeDB // The database handler for maintaining contract codes.
|
||||
jumpDest *JumpDestCache // Shared JUMPDEST analysis cache for block processing
|
||||
jumpDest vm.JumpDestCache // Shared JUMPDEST analysis cache for block processing
|
||||
txIndexer *txIndexer // Transaction indexer, might be nil if not enabled
|
||||
|
||||
hc *HeaderChain
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ const (
|
|||
jumpDestBucketSize = 8 * 1024 * 1024
|
||||
)
|
||||
|
||||
// JumpDestCache is a thread-safe, byte-bounded LRU of JUMPDEST analysis
|
||||
// shardedJumpDestCache is a thread-safe, byte-bounded LRU of JUMPDEST analysis
|
||||
// bitmaps, sharded into independent buckets to reduce lock contention. It is
|
||||
// owned by BlockChain and shared across block processing and prefetching,
|
||||
// keyed by the immutable contract code hash.
|
||||
type JumpDestCache struct {
|
||||
type shardedJumpDestCache struct {
|
||||
buckets [jumpDestBuckets]struct {
|
||||
dest *lru.SizeConstrainedCache[common.Hash, vm.BitVec]
|
||||
}
|
||||
}
|
||||
|
||||
// NewJumpDestCache constructs the analysis cache.
|
||||
func NewJumpDestCache() *JumpDestCache {
|
||||
c := new(JumpDestCache)
|
||||
func NewJumpDestCache() vm.JumpDestCache {
|
||||
c := new(shardedJumpDestCache)
|
||||
for i := range c.buckets {
|
||||
c.buckets[i].dest = lru.NewSizeConstrainedCache[common.Hash, vm.BitVec](jumpDestBucketSize)
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ func NewJumpDestCache() *JumpDestCache {
|
|||
}
|
||||
|
||||
// Load retrieves the cached jumpdest analysis for the given code hash.
|
||||
func (c *JumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
|
||||
func (c *shardedJumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
|
||||
bucket := &c.buckets[hash[0]&(jumpDestBuckets-1)]
|
||||
v, ok := bucket.dest.Get(hash)
|
||||
if ok {
|
||||
|
|
@ -70,7 +70,7 @@ func (c *JumpDestCache) Load(hash common.Hash) (vm.BitVec, bool) {
|
|||
}
|
||||
|
||||
// Store saves the jumpdest analysis for the given code hash.
|
||||
func (c *JumpDestCache) Store(hash common.Hash, b vm.BitVec) {
|
||||
func (c *shardedJumpDestCache) Store(hash common.Hash, b vm.BitVec) {
|
||||
bucket := &c.buckets[hash[0]&(jumpDestBuckets-1)]
|
||||
bucket.dest.Add(hash, b)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func newStatePrefetcher(config *params.ChainConfig, chain *HeaderChain) *statePr
|
|||
// Prefetch processes the state changes according to the Ethereum rules by running
|
||||
// the transaction messages using the statedb, but any changes are discarded. The
|
||||
// only goal is to warm the state caches.
|
||||
func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config, interrupt *atomic.Bool) {
|
||||
func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config, interrupt *atomic.Bool) {
|
||||
var (
|
||||
fails atomic.Int64
|
||||
header = block.Header()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (p *StateProcessor) chainConfig() *params.ChainConfig {
|
|||
// Process returns the receipts and logs accumulated during the process and
|
||||
// returns the amount of gas that was used in the process. If any of the
|
||||
// transactions failed to execute due to insufficient gas it will return an error.
|
||||
func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config) (*ProcessResult, error) {
|
||||
func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config) (*ProcessResult, error) {
|
||||
var (
|
||||
config = p.chainConfig()
|
||||
receipts = make(types.Receipts, 0, len(block.Transactions()))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type Prefetcher interface {
|
|||
// Prefetch processes the state changes according to the Ethereum rules by running
|
||||
// the transaction messages using the statedb, but any changes are discarded. The
|
||||
// only goal is to pre-cache transaction signatures and state trie nodes.
|
||||
Prefetch(block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config, interrupt *atomic.Bool)
|
||||
Prefetch(block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config, interrupt *atomic.Bool)
|
||||
}
|
||||
|
||||
// Processor is an interface for processing blocks using a given initial state.
|
||||
|
|
@ -49,7 +49,7 @@ type Processor interface {
|
|||
// Process processes the state changes according to the Ethereum rules by running
|
||||
// the transaction messages using the statedb and applying any rewards to both
|
||||
// the processor (coinbase) and any included uncles.
|
||||
Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests *JumpDestCache, cfg vm.Config) (*ProcessResult, error)
|
||||
Process(ctx context.Context, block *types.Block, statedb *state.StateDB, jumpDests vm.JumpDestCache, cfg vm.Config) (*ProcessResult, error)
|
||||
}
|
||||
|
||||
// ProcessResult contains the values computed by Process.
|
||||
|
|
|
|||
Loading…
Reference in a new issue