forked from cerc-io/plugeth
core, eth, trie: expose more detailed dirty ram tracking for diff layers (#27971)
This commit is contained in:
@@ -852,3 +852,21 @@ func (t *Tree) DiskRoot() common.Hash {
|
||||
|
||||
return t.diskRoot()
|
||||
}
|
||||
|
||||
// Size returns the memory usage of the diff layers above the disk layer and the
|
||||
// dirty nodes buffered in the disk layer. Currently, the implementation uses a
|
||||
// special diff layer (the first) as an aggregator simulating a dirty buffer, so
|
||||
// the second return will always be 0. However, this will be made consistent with
|
||||
// the pathdb, which will require a second return.
|
||||
func (t *Tree) Size() (diffs common.StorageSize, buf common.StorageSize) {
|
||||
t.lock.RLock()
|
||||
defer t.lock.RUnlock()
|
||||
|
||||
var size common.StorageSize
|
||||
for _, layer := range t.layers {
|
||||
if layer, ok := layer.(*diffLayer); ok {
|
||||
size += common.StorageSize(layer.memory)
|
||||
}
|
||||
}
|
||||
return size, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user