@ethereumjs/statemanager / StorageCache
Cache
↳ StorageCache
• new StorageCache(opts
)
Name | Type |
---|---|
opts |
CacheOpts |
Cache.constructor
• _checkpoints: number
= 0
Cache._checkpoints
• _debug: Debugger
Cache._debug
• _diffCache: Map
<string
, DiffStorageCacheMap
>[] = []
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
, StorageCacheMap
, unknown
>
• _orderedMapCache: undefined
| OrderedMap
<string
, StorageCacheMap
>
• _stats: Object
Name | Type |
---|---|
dels |
number |
hits |
number |
reads |
number |
size |
number |
writes |
number |
Cache._stats
▸ _saveCachePreState(addressHex
, keyHex
): void
Name | Type |
---|---|
addressHex |
string |
keyHex |
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
▸ clearContractStorage(address
): void
Deletes all storage slots for address from the cache
Name | Type |
---|---|
address |
Address |
void
▸ commit(): void
Commits to current state of cache (no effect on trie).
void
▸ del(address
, key
): void
Marks storage key for address as deleted in cache.
Name | Type | Description |
---|---|---|
address |
Address |
Address |
key |
Uint8Array |
Storage key |
void
▸ dump(address
): undefined
| StorageCacheMap
Dumps the RLP-encoded storage values for an account
specified by address
.
Name | Type | Description |
---|---|---|
address |
Address |
The address of the account to return storage for |
undefined
| StorageCacheMap
account
or undefined if the account
is not in the cache▸ flush(): [string
, string
, undefined
| Uint8Array
][]
Flushes cache by returning storage slots that have been modified or deleted and resetting the diff cache (at checkpoint height).
[string
, string
, undefined
| Uint8Array
][]
▸ get(address
, key
): undefined
| Uint8Array
Returns the queried slot as the RLP encoded storage value hexToBytes(‘0x80’): slot is known to be empty undefined: slot is not in cache
Name | Type | Description |
---|---|---|
address |
Address |
Address of account |
key |
Uint8Array |
Storage key |
undefined
| Uint8Array
Storage value or undefined
▸ put(address
, key
, value
): void
Puts storage value to cache under address_key cache key.
Name | Type | Description |
---|---|---|
address |
Address |
Account address |
key |
Uint8Array |
Storage key |
value |
Uint8Array |
- |
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 |