Skip to content

Commit

Permalink
core/rawdb, ethdb: rename AtomicReadAncients -> ReadAncients
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Sep 20, 2021
1 parent bc7dfe5 commit 2a0c9dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions core/rawdb/accessors_chain.go
Expand Up @@ -35,7 +35,7 @@ import (
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
func ReadCanonicalHash(db ethdb.Reader, number uint64) common.Hash {
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
data, _ = reader.Ancient(freezerHashTable, number)
if len(data) == 0 {
// Get it by hash from leveldb
Expand Down Expand Up @@ -299,7 +299,7 @@ func WriteFastTxLookupLimit(db ethdb.KeyValueWriter, number uint64) {
// ReadHeaderRLP retrieves a block header in its raw RLP database encoding.
func ReadHeaderRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
// First try to look up the data in ancient database. Extra hash
// comparison is necessary since ancient database only maintains
// the canonical data.
Expand Down Expand Up @@ -393,7 +393,7 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
// comparison is necessary since ancient database only maintains
// the canonical data.
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
// Check if the data is in ancients
if isCanon(reader, number, hash) {
data, _ = reader.Ancient(freezerBodiesTable, number)
Expand All @@ -410,7 +410,7 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
// block at number, in RLP encoding.
func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
data, _ = reader.Ancient(freezerBodiesTable, number)
if len(data) > 0 {
return nil
Expand Down Expand Up @@ -473,7 +473,7 @@ func DeleteBody(db ethdb.KeyValueWriter, hash common.Hash, number uint64) {
// ReadTdRLP retrieves a block's total difficulty corresponding to the hash in RLP encoding.
func ReadTdRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
// Check if the data is in ancients
if isCanon(reader, number, hash) {
data, _ = reader.Ancient(freezerDifficultyTable, number)
Expand Down Expand Up @@ -533,7 +533,7 @@ func HasReceipts(db ethdb.Reader, hash common.Hash, number uint64) bool {
// ReadReceiptsRLP retrieves all the transaction receipts belonging to a block in RLP encoding.
func ReadReceiptsRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
var data []byte
db.AtomicReadAncients(func(reader ethdb.AncientReader) error {
db.ReadAncients(func(reader ethdb.AncientReader) error {
// Check if the data is in ancients
if isCanon(reader, number, hash) {
data, _ = reader.Ancient(freezerReceiptTable, number)
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/database.go
Expand Up @@ -119,7 +119,7 @@ func (db *nofreezedb) Sync() error {
return errNotSupported
}

func (db *nofreezedb) AtomicReadAncients(fn func(reader ethdb.AncientReader) error) (err error) {
func (db *nofreezedb) ReadAncients(fn func(reader ethdb.AncientReader) error) (err error) {
// Unlike other ancient-related methods, this method does not return
// errNotSupported when invoked.
// The reason for this is that the caller might want to do several things:
Expand Down
4 changes: 2 additions & 2 deletions core/rawdb/freezer.go
Expand Up @@ -232,9 +232,9 @@ func (f *freezer) AncientSize(kind string) (uint64, error) {
return 0, errUnknownTable
}

// AtomicReadAncients runs the given read operation while ensuring that no writes take place
// ReadAncients runs the given read operation while ensuring that no writes take place
// on the underlying freezer.
func (f *freezer) AtomicReadAncients(fn func(ethdb.AncientReader) error) (err error) {
func (f *freezer) ReadAncients(fn func(ethdb.AncientReader) error) (err error) {
f.writeLock.RLock()
defer f.writeLock.RUnlock()
return fn(f)
Expand Down
4 changes: 2 additions & 2 deletions core/rawdb/table.go
Expand Up @@ -85,8 +85,8 @@ func (t *table) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (int64, erro
return t.db.ModifyAncients(fn)
}

func (t *table) AtomicReadAncients(fn func(reader ethdb.AncientReader) error) (err error) {
return t.db.AtomicReadAncients(fn)
func (t *table) ReadAncients(fn func(reader ethdb.AncientReader) error) (err error) {
return t.db.ReadAncients(fn)
}

// TruncateAncients is a noop passthrough that just forwards the request to the underlying
Expand Down
4 changes: 2 additions & 2 deletions ethdb/database.go
Expand Up @@ -93,9 +93,9 @@ type AncientReader interface {
// AncientBatchReader is the interface for 'batched' or 'atomic' reading.
type AncientBatchReader interface {
AncientReader
// AtomicReadAncients runs the given read operation while ensuring that no writes take place
// ReadAncients runs the given read operation while ensuring that no writes take place
// on the underlying freezer.
AtomicReadAncients(fn func(AncientReader) error) (err error)
ReadAncients(fn func(AncientReader) error) (err error)
}

// AncientWriter contains the methods required to write to immutable ancient data.
Expand Down

0 comments on commit 2a0c9dd

Please sign in to comment.