core/rawdb, ethdb: remove HasAncient

We don't use it anywhere.
This commit is contained in:
Felix Lange 2025-05-19 16:56:14 +02:00 committed by lightclient
parent 52464bffbe
commit cc914b49e0
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
9 changed files with 0 additions and 78 deletions

View file

@ -77,13 +77,6 @@ func basicRead(t *testing.T, newFn func(kinds []string) ethdb.AncientStore) {
} }
for _, c := range cases { for _, c := range cases {
for i := c.start; i < c.limit; i++ { for i := c.start; i < c.limit; i++ {
exist, err := db.HasAncient("a", uint64(i))
if err != nil {
t.Fatalf("Failed to check presence, %v", err)
}
if exist {
t.Fatalf("Item %d is already truncated", uint64(i))
}
_, err = db.Ancient("a", uint64(i)) _, err = db.Ancient("a", uint64(i))
if err == nil { if err == nil {
t.Fatal("Error is expected for non-existent item") t.Fatal("Error is expected for non-existent item")
@ -93,13 +86,6 @@ func basicRead(t *testing.T, newFn func(kinds []string) ethdb.AncientStore) {
// Test the items in range should be reachable // Test the items in range should be reachable
for i := 10; i < 90; i++ { for i := 10; i < 90; i++ {
exist, err := db.HasAncient("a", uint64(i))
if err != nil {
t.Fatalf("Failed to check presence, %v", err)
}
if !exist {
t.Fatalf("Item %d is missing", uint64(i))
}
blob, err := db.Ancient("a", uint64(i)) blob, err := db.Ancient("a", uint64(i))
if err != nil { if err != nil {
t.Fatalf("Failed to retrieve item, %v", err) t.Fatalf("Failed to retrieve item, %v", err)
@ -110,13 +96,6 @@ func basicRead(t *testing.T, newFn func(kinds []string) ethdb.AncientStore) {
} }
// Test the items in unknown table shouldn't be reachable // Test the items in unknown table shouldn't be reachable
exist, err := db.HasAncient("b", uint64(0))
if err != nil {
t.Fatalf("Failed to check presence, %v", err)
}
if exist {
t.Fatal("Item in unknown table shouldn't be found")
}
_, err = db.Ancient("b", uint64(0)) _, err = db.Ancient("b", uint64(0))
if err == nil { if err == nil {
t.Fatal("Error is expected for unknown table") t.Fatal("Error is expected for unknown table")

View file

@ -86,11 +86,6 @@ type nofreezedb struct {
ethdb.KeyValueStore ethdb.KeyValueStore
} }
// HasAncient returns an error as we don't have a backing chain freezer.
func (db *nofreezedb) HasAncient(kind string, number uint64) (bool, error) {
return false, errNotSupported
}
// Ancient returns an error as we don't have a backing chain freezer. // Ancient returns an error as we don't have a backing chain freezer.
func (db *nofreezedb) Ancient(kind string, number uint64) ([]byte, error) { func (db *nofreezedb) Ancient(kind string, number uint64) ([]byte, error) {
return nil, errNotSupported return nil, errNotSupported

View file

@ -180,15 +180,6 @@ func (f *Freezer) AncientDatadir() (string, error) {
return f.datadir, nil return f.datadir, nil
} }
// HasAncient returns an indicator whether the specified ancient data exists
// in the freezer.
func (f *Freezer) HasAncient(kind string, number uint64) (bool, error) {
if table := f.tables[kind]; table != nil {
return table.has(number), nil
}
return false, nil
}
// Ancient retrieves an ancient binary blob from the append-only immutable files. // Ancient retrieves an ancient binary blob from the append-only immutable files.
func (f *Freezer) Ancient(kind string, number uint64) ([]byte, error) { func (f *Freezer) Ancient(kind string, number uint64) ([]byte, error) {
if table := f.tables[kind]; table != nil { if table := f.tables[kind]; table != nil {

View file

@ -232,17 +232,6 @@ func NewMemoryFreezer(readonly bool, tableName map[string]freezerTableConfig) *M
} }
} }
// HasAncient returns an indicator whether the specified data exists.
func (f *MemoryFreezer) HasAncient(kind string, number uint64) (bool, error) {
f.lock.RLock()
defer f.lock.RUnlock()
if table := f.tables[kind]; table != nil {
return table.has(number), nil
}
return false, nil
}
// Ancient retrieves an ancient binary blob from the in-memory freezer. // Ancient retrieves an ancient binary blob from the in-memory freezer.
func (f *MemoryFreezer) Ancient(kind string, number uint64) ([]byte, error) { func (f *MemoryFreezer) Ancient(kind string, number uint64) ([]byte, error) {
f.lock.RLock() f.lock.RLock()

View file

@ -105,15 +105,6 @@ func (f *resettableFreezer) Close() error {
return f.freezer.Close() return f.freezer.Close()
} }
// HasAncient returns an indicator whether the specified ancient data exists
// in the freezer
func (f *resettableFreezer) HasAncient(kind string, number uint64) (bool, error) {
f.lock.RLock()
defer f.lock.RUnlock()
return f.freezer.HasAncient(kind, number)
}
// Ancient retrieves an ancient binary blob from the append-only immutable files. // Ancient retrieves an ancient binary blob from the append-only immutable files.
func (f *resettableFreezer) Ancient(kind string, number uint64) ([]byte, error) { func (f *resettableFreezer) Ancient(kind string, number uint64) ([]byte, error) {
f.lock.RLock() f.lock.RLock()

View file

@ -357,9 +357,6 @@ func checkAncientCount(t *testing.T, f *Freezer, kind string, n uint64) {
// Check at index n-1. // Check at index n-1.
if n > 0 { if n > 0 {
index := n - 1 index := n - 1
if ok, _ := f.HasAncient(kind, index); !ok {
t.Errorf("HasAncient(%q, %d) returned false unexpectedly", kind, index)
}
if _, err := f.Ancient(kind, index); err != nil { if _, err := f.Ancient(kind, index); err != nil {
t.Errorf("Ancient(%q, %d) returned unexpected error %q", kind, index, err) t.Errorf("Ancient(%q, %d) returned unexpected error %q", kind, index, err)
} }
@ -367,9 +364,6 @@ func checkAncientCount(t *testing.T, f *Freezer, kind string, n uint64) {
// Check at index n. // Check at index n.
index := n index := n
if ok, _ := f.HasAncient(kind, index); ok {
t.Errorf("HasAncient(%q, %d) returned true unexpectedly", kind, index)
}
if _, err := f.Ancient(kind, index); err == nil { if _, err := f.Ancient(kind, index); err == nil {
t.Errorf("Ancient(%q, %d) didn't return expected error", kind, index) t.Errorf("Ancient(%q, %d) didn't return expected error", kind, index)
} else if err != errOutOfBounds { } else if err != errOutOfBounds {

View file

@ -50,12 +50,6 @@ func (t *table) Get(key []byte) ([]byte, error) {
return t.db.Get(append([]byte(t.prefix), key...)) return t.db.Get(append([]byte(t.prefix), key...))
} }
// HasAncient is a noop passthrough that just forwards the request to the underlying
// database.
func (t *table) HasAncient(kind string, number uint64) (bool, error) {
return t.db.HasAncient(kind, number)
}
// Ancient is a noop passthrough that just forwards the request to the underlying // Ancient is a noop passthrough that just forwards the request to the underlying
// database. // database.
func (t *table) Ancient(kind string, number uint64) ([]byte, error) { func (t *table) Ancient(kind string, number uint64) ([]byte, error) {

View file

@ -92,10 +92,6 @@ type KeyValueStore interface {
// AncientReaderOp contains the methods required to read from immutable ancient data. // AncientReaderOp contains the methods required to read from immutable ancient data.
type AncientReaderOp interface { type AncientReaderOp interface {
// HasAncient returns an indicator whether the specified data exists in the
// ancient store.
HasAncient(kind string, number uint64) (bool, error)
// Ancient retrieves an ancient binary blob from the append-only immutable files. // Ancient retrieves an ancient binary blob from the append-only immutable files.
Ancient(kind string, number uint64) ([]byte, error) Ancient(kind string, number uint64) ([]byte, error)

View file

@ -48,13 +48,6 @@ func (db *Database) Get(key []byte) ([]byte, error) {
return resp, nil return resp, nil
} }
func (db *Database) HasAncient(kind string, number uint64) (bool, error) {
if _, err := db.Ancient(kind, number); err != nil {
return false, err
}
return true, nil
}
func (db *Database) Ancient(kind string, number uint64) ([]byte, error) { func (db *Database) Ancient(kind string, number uint64) ([]byte, error) {
var resp hexutil.Bytes var resp hexutil.Bytes
err := db.remote.Call(&resp, "debug_dbAncient", kind, number) err := db.remote.Call(&resp, "debug_dbAncient", kind, number)