diff --git a/ethdb/kv_lmdb.go b/ethdb/kv_lmdb.go index d0038e964..3eb11c17d 100644 --- a/ethdb/kv_lmdb.go +++ b/ethdb/kv_lmdb.go @@ -309,11 +309,11 @@ func (db *LmdbKV) Close() { } func (db *LmdbKV) DiskSize(_ context.Context) (uint64, error) { - stats, err := db.env.Stat() + fileInfo, err := os.Stat(path.Join(db.opts.path, "data.mdb")) if err != nil { - return 0, fmt.Errorf("could not read database size: %w", err) + return 0, err } - return uint64(stats.PSize) * (stats.LeafPages + stats.BranchPages + stats.OverflowPages), nil + return uint64(fileInfo.Size()), nil } func (db *LmdbKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) { diff --git a/ethdb/kv_mdbx.go b/ethdb/kv_mdbx.go index 6e5f211f2..973666a85 100644 --- a/ethdb/kv_mdbx.go +++ b/ethdb/kv_mdbx.go @@ -269,11 +269,11 @@ func (db *MdbxKV) NewDbWithTheSameParameters() *ObjectDatabase { } func (db *MdbxKV) DiskSize(_ context.Context) (uint64, error) { - stats, err := db.env.Stat() + fileInfo, err := os.Stat(path.Join(db.opts.path, "mdbx.dat")) if err != nil { - return 0, fmt.Errorf("could not read database size: %w", err) + return 0, err } - return uint64(stats.PSize) * (stats.LeafPages + stats.BranchPages + stats.OverflowPages), nil + return uint64(fileInfo.Size()), nil } func (db *MdbxKV) Begin(_ context.Context, parent Tx, flags TxFlags) (Tx, error) {