Skip to content

Latest commit

 

History

History
359 lines (200 loc) · 7 KB

File metadata and controls

359 lines (200 loc) · 7 KB

@ethereumjs/statemanager / CodeCache

Class: CodeCache

Hierarchy

  • Cache

    CodeCache

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new CodeCache(opts)

Parameters

Name Type
opts CacheOpts

Overrides

Cache.constructor

Defined in

cache/code.ts:36

Properties

_checkpoints

_checkpoints: number = 0

Inherited from

Cache._checkpoints

Defined in

cache/cache.ts:9


_debug

_debug: Debugger

Inherited from

Cache._debug

Defined in

cache/cache.ts:7


_diffCache

_diffCache: Map<string, undefined | CodeCacheElement>[] = []

Diff cache collecting the state of the cache at the beginning of checkpoint height (respectively: before a first modification)

If the whole cache element is undefined (in contrast to the code), the element didn't exist in the cache before.

Defined in

cache/code.ts:34


_lruCache

_lruCache: undefined | LRUCache<string, CodeCacheElement, unknown>

Defined in

cache/code.ts:22


_orderedMapCache

_orderedMapCache: undefined | OrderedMap<string, CodeCacheElement>

Defined in

cache/code.ts:23


_stats

_stats: Object

Type declaration

Name Type
dels number
hits number
reads number
size number
writes number

Inherited from

Cache._stats

Defined in

cache/cache.ts:11

Methods

_saveCachePreState

_saveCachePreState(cacheKeyHex): void

Saves the state of the code cache before making changes to it.

Parameters

Name Type Description
cacheKeyHex string Account key for which code is being modified.

Returns

void

Defined in

cache/code.ts:56


checkpoint

checkpoint(): void

Marks the current state of the cache as a checkpoint, which can later be reverted or committed.

Returns

void

Defined in

cache/code.ts:222


clear

clear(): void

Clears the cache.

Returns

void

Defined in

cache/code.ts:266


commit

commit(): void

Commits the current state of the cache (no effect on trie).

Returns

void

Defined in

cache/code.ts:202


del

del(address): void

Marks code as deleted in the cache.

Parameters

Name Type Description
address Address Account address for which code is being fetched.

Returns

void

Defined in

cache/code.ts:122


flush

flush(): [string, CodeCacheElement][]

Flushes the cache by returning codes that have been modified or deleted and resetting the diff cache (at checkpoint height).

Returns

[string, CodeCacheElement][]

Defined in

cache/code.ts:145


get

get(address): undefined | CodeCacheElement

Returns the queried code or undefined if it doesn't exist.

Parameters

Name Type Description
address Address Account address for which code is being fetched.

Returns

undefined | CodeCacheElement

Defined in

cache/code.ts:98


put

put(address, code): void

Puts code into the cache under its hash.

Parameters

Name Type Description
address Address Address of account code is being modified for.
code undefined | Uint8Array Bytecode or undefined if code doesn't exist.

Returns

void

Defined in

cache/code.ts:75


revert

revert(): void

Revert changes to the cache to the last checkpoint (no effect on trie).

Returns

void

Defined in

cache/code.ts:174


size

size(): number

Returns the size of the cache

Returns

number

Defined in

cache/code.ts:234


stats

stats(reset?): any

Returns a dictionary with cache statistics.

Parameters

Name Type Default value Description
reset boolean true Whether to reset statistics after retrieval.

Returns

any

A dictionary with cache statistics.

Defined in

cache/code.ts:248