Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions triedb/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ type NodeReader interface {
// node path and the corresponding node hash. No error will be returned
// if the node is not found.
//
// The returned node content won't be changed after the call.
// IMPORTANT: The returned byte slice is a direct reference to internal
// database storage and MUST NOT be modified. Any modification will
// corrupt the database state and cause undefined behavior. The slice
// is safe to read from but must be treated as read-only.
//
// Don't modify the returned byte slice since it's not deep-copied and
// still be referenced by database.
// For performance reasons, the data is not deep-copied. If you need
// to modify the data, create a copy using common.CopyBytes().
Node(owner common.Hash, path []byte, hash common.Hash) ([]byte, error)
}

Expand All @@ -56,8 +59,15 @@ type StateReader interface {
// within a particular account. An error will be returned if the read operation
// exits abnormally.
//
// IMPORTANT: The returned byte slice is a direct reference to internal
// database storage and MUST NOT be modified. Any modification will
// corrupt the database state and cause undefined behavior. The slice
// is safe to read from but must be treated as read-only.
//
// For performance reasons, the data is not deep-copied. If you need
// to modify the data, create a copy using common.CopyBytes().
//
// Note:
// - the returned storage data is not a copy, please don't modify it
// - no error will be returned if the requested slot is not found in database
Storage(accountHash, storageHash common.Hash) ([]byte, error)
}
Expand Down