forked from cerc-io/plugeth
cmd, core, ethdb, node: move chain freezer one folder deeper (#25487)
* cmd, core, ethdb, node: create chain freezer in a sub folder * core/rawdb: remove unused code * core, ethdb, node: add AncientDatadir API back * cmd, core: extend freezer info dump for sub-ancient-store * core/rawdb: rework freezer inspector * core/rawdb: address comments from Peter * core/rawdb: fix build issue
This commit is contained in:
+13
-9
@@ -703,7 +703,7 @@ func (n *Node) OpenDatabase(name string, cache, handles int, namespace string, r
|
||||
// also attaching a chain freezer to it that moves ancient chain data from the
|
||||
// database to immutable append-only files. If the node is an ephemeral one, a
|
||||
// memory database is returned.
|
||||
func (n *Node) OpenDatabaseWithFreezer(name string, cache, handles int, freezer, namespace string, readonly bool) (ethdb.Database, error) {
|
||||
func (n *Node) OpenDatabaseWithFreezer(name string, cache, handles int, ancient string, namespace string, readonly bool) (ethdb.Database, error) {
|
||||
n.lock.Lock()
|
||||
defer n.lock.Unlock()
|
||||
if n.state == closedState {
|
||||
@@ -715,14 +715,7 @@ func (n *Node) OpenDatabaseWithFreezer(name string, cache, handles int, freezer,
|
||||
if n.config.DataDir == "" {
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
} else {
|
||||
root := n.ResolvePath(name)
|
||||
switch {
|
||||
case freezer == "":
|
||||
freezer = filepath.Join(root, "ancient")
|
||||
case !filepath.IsAbs(freezer):
|
||||
freezer = n.ResolvePath(freezer)
|
||||
}
|
||||
db, err = rawdb.NewLevelDBDatabaseWithFreezer(root, cache, handles, freezer, namespace, readonly)
|
||||
db, err = rawdb.NewLevelDBDatabaseWithFreezer(n.ResolvePath(name), cache, handles, n.ResolveAncient(name, ancient), namespace, readonly)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
@@ -736,6 +729,17 @@ func (n *Node) ResolvePath(x string) string {
|
||||
return n.config.ResolvePath(x)
|
||||
}
|
||||
|
||||
// ResolveAncient returns the absolute path of the root ancient directory.
|
||||
func (n *Node) ResolveAncient(name string, ancient string) string {
|
||||
switch {
|
||||
case ancient == "":
|
||||
ancient = filepath.Join(n.ResolvePath(name), "ancient")
|
||||
case !filepath.IsAbs(ancient):
|
||||
ancient = n.ResolvePath(ancient)
|
||||
}
|
||||
return ancient
|
||||
}
|
||||
|
||||
// closeTrackingDB wraps the Close method of a database. When the database is closed by the
|
||||
// service, the wrapper removes it from the node's database map. This ensures that Node
|
||||
// won't auto-close the database if it is closed by the service that opened it.
|
||||
|
||||
Reference in New Issue
Block a user