@ethereumjs/statemanager / AccountCache
Cache
↳ AccountCache
• new AccountCache(opts)
| Name | Type |
|---|---|
opts |
CacheOpts |
Cache.constructor
• _checkpoints: number = 0
Cache._checkpoints
• _debug: Debugger
Cache._debug
• _diffCache: Map<string, undefined | AccountCacheElement>[] = []
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 account), the element didn’t exist in the cache before.
• _lruCache: undefined | LRUCache<string, AccountCacheElement, unknown>
• _orderedMapCache: undefined | OrderedMap<string, AccountCacheElement>
• _stats: Object
| Name | Type |
|---|---|
dels |
number |
hits |
number |
reads |
number |
size |
number |
writes |
number |
Cache._stats
▸ _saveCachePreState(cacheKeyHex): void
| Name | Type |
|---|---|
cacheKeyHex |
string |
void
▸ checkpoint(): void
Marks current state of cache as checkpoint, which can later on be reverted or committed.
void
▸ clear(): void
Clears cache.
void
▸ commit(): void
Commits to current state of cache (no effect on trie).
void
▸ del(address): void
Marks address as deleted in cache.
| Name | Type | Description |
|---|---|---|
address |
Address |
Address |
void
▸ flush(): [string, AccountCacheElement][]
Flushes cache by returning accounts that have been modified or deleted and resetting the diff cache (at checkpoint height).
[string, AccountCacheElement][]
▸ get(address): undefined | AccountCacheElement
Returns the queried account or undefined if account doesn’t exist
| Name | Type | Description |
|---|---|---|
address |
Address |
Address of account |
undefined | AccountCacheElement
▸ put(address, account): void
Puts account to cache under its address.
| Name | Type | Description |
|---|---|---|
address |
Address |
Address of account |
account |
undefined | Account |
Account or undefined if account doesn’t exist in the trie |
void
▸ revert(): void
Revert changes to cache last checkpoint (no effect on trie).
void
▸ size(): number
Returns the size of the cache
number
▸ stats(reset?): Object
Returns a dict with cache stats
| Name | Type | Default value |
|---|---|---|
reset |
boolean |
true |
Object
| Name | Type |
|---|---|
dels |
number |
hits |
number |
reads |
number |
size |
number |
writes |
number |