Update database.go

This commit is contained in:
Adrian 2025-09-12 18:52:05 +02:00 committed by GitHub
parent 5d09aa316f
commit 6b2a215b2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,10 +27,13 @@ type NodeReader interface {
// node path and the corresponding node hash. No error will be returned // node path and the corresponding node hash. No error will be returned
// if the node is not found. // 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 // For performance reasons, the data is not deep-copied. If you need
// still be referenced by database. // to modify the data, create a copy using common.CopyBytes().
Node(owner common.Hash, path []byte, hash common.Hash) ([]byte, error) Node(owner common.Hash, path []byte, hash common.Hash) ([]byte, error)
} }
@ -56,8 +59,15 @@ type StateReader interface {
// within a particular account. An error will be returned if the read operation // within a particular account. An error will be returned if the read operation
// exits abnormally. // 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: // 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 // - no error will be returned if the requested slot is not found in database
Storage(accountHash, storageHash common.Hash) ([]byte, error) Storage(accountHash, storageHash common.Hash) ([]byte, error)
} }