|
|
@ -140,6 +140,11 @@ func (dl *diskLayer) node(owner common.Hash, path []byte, depth int) ([]byte, co |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
blob = rawdb.ReadStorageTrieNode(dl.db.diskdb, owner, path) |
|
|
|
blob = rawdb.ReadStorageTrieNode(dl.db.diskdb, owner, path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Store the resolved data in the clean cache. The background buffer flusher
|
|
|
|
|
|
|
|
// may also write to the clean cache concurrently, but two writers cannot
|
|
|
|
|
|
|
|
// write the same item with different content. If the item already exists,
|
|
|
|
|
|
|
|
// it will be found in the frozen buffer, eliminating the need to check the
|
|
|
|
|
|
|
|
// database.
|
|
|
|
if dl.cleans != nil && len(blob) > 0 { |
|
|
|
if dl.cleans != nil && len(blob) > 0 { |
|
|
|
dl.cleans.Set(key, blob) |
|
|
|
dl.cleans.Set(key, blob) |
|
|
|
cleanWriteMeter.Mark(int64(len(blob))) |
|
|
|
cleanWriteMeter.Mark(int64(len(blob))) |
|
|
@ -208,7 +213,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) { |
|
|
|
if combined.full() || force { |
|
|
|
if combined.full() || force { |
|
|
|
// Wait until the previous frozen buffer is fully flushed
|
|
|
|
// Wait until the previous frozen buffer is fully flushed
|
|
|
|
if dl.frozen != nil { |
|
|
|
if dl.frozen != nil { |
|
|
|
if err := dl.frozen.flushed(); err != nil { |
|
|
|
if err := dl.frozen.waitFlush(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -221,7 +226,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) { |
|
|
|
// Block until the frozen buffer is fully flushed out if the oldest history
|
|
|
|
// Block until the frozen buffer is fully flushed out if the oldest history
|
|
|
|
// surpasses the persisted state ID.
|
|
|
|
// surpasses the persisted state ID.
|
|
|
|
if persistedID < oldest { |
|
|
|
if persistedID < oldest { |
|
|
|
if err := dl.frozen.flushed(); err != nil { |
|
|
|
if err := dl.frozen.waitFlush(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -278,10 +283,12 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Block until the frozen buffer is fully flushed
|
|
|
|
// Block until the frozen buffer is fully flushed
|
|
|
|
if dl.frozen != nil { |
|
|
|
if dl.frozen != nil { |
|
|
|
if err := dl.frozen.flushed(); err != nil { |
|
|
|
if err := dl.frozen.waitFlush(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
dl.frozen = nil // unset the frozen buffer
|
|
|
|
// Unset the frozen buffer if it exists, otherwise these "reverted"
|
|
|
|
|
|
|
|
// states will still be accessible after revert in frozen buffer.
|
|
|
|
|
|
|
|
dl.frozen = nil |
|
|
|
} |
|
|
|
} |
|
|
|
batch := dl.db.diskdb.NewBatch() |
|
|
|
batch := dl.db.diskdb.NewBatch() |
|
|
|
writeNodes(batch, nodes, dl.cleans) |
|
|
|
writeNodes(batch, nodes, dl.cleans) |
|
|
|