@ethereumjs/statemanager / CodeCache
Cache
↳ CodeCache
• new CodeCache(opts
)
Name | Type |
---|---|
opts |
CacheOpts |
Cache.constructor
• _checkpoints: number
= 0
Cache._checkpoints
• _debug: Debugger
Cache._debug
• _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.
• _lruCache: undefined
| LRUCache
<string
, CodeCacheElement
, unknown
>
• _orderedMapCache: undefined
| OrderedMap
<string
, CodeCacheElement
>
• _stats: Object
Name | Type |
---|---|
dels |
number |
hits |
number |
reads |
number |
size |
number |
writes |
number |
Cache._stats
▸ _saveCachePreState(cacheKeyHex
): void
Saves the state of the code cache before making changes to it.
Name | Type | Description |
---|---|---|
cacheKeyHex |
string |
Account key for which code is being modified. |
void
▸ checkpoint(): void
Marks the current state of the cache as a checkpoint, which can later be reverted or committed.
void
▸ clear(): void
Clears the cache.
void
▸ commit(): void
Commits the current state of the cache (no effect on trie).
void
▸ del(address
): void
Marks code as deleted in the cache.
Name | Type | Description |
---|---|---|
address |
Address |
Account address for which code is being fetched. |
void
▸ flush(): [string
, CodeCacheElement
][]
Flushes the cache by returning codes that have been modified or deleted and resetting the diff cache (at checkpoint height).
[string
, CodeCacheElement
][]
▸ get(address
): undefined
| CodeCacheElement
Returns the queried code or undefined if it doesn’t exist.
Name | Type | Description |
---|---|---|
address |
Address |
Account address for which code is being fetched. |
undefined
| CodeCacheElement
▸ put(address
, code
): void
Puts code into the cache under its hash.
Name | Type | Description |
---|---|---|
address |
Address |
Address of account code is being modified for. |
code |
undefined | Uint8Array |
Bytecode or undefined if code doesn’t exist. |
void
▸ revert(): void
Revert changes to the cache to the last checkpoint (no effect on trie).
void
▸ size(): number
Returns the size of the cache
number
▸ stats(reset?
): any
Returns a dictionary with cache statistics.
Name | Type | Default value | Description |
---|---|---|---|
reset |
boolean |
true |
Whether to reset statistics after retrieval. |
any
A dictionary with cache statistics.