Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove TODO comment and improve FindDbsInPath documentation #1055

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions v2/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ func (sql *SqliteDb) ImportSnapshotFromTable(version int64, traverseOrder Traver
}

func (sql *SqliteDb) ImportMostRecentSnapshot(targetVersion int64, traverseOrder TraverseOrderType, loadLeaves bool) (*Node, int64, error) {
// First check if we need to find the database paths
if sql.opts.Path == "" {
return nil, 0, fmt.Errorf("database path is empty")
}

read, err := sql.getReadConn()
if err != nil {
return nil, 0, err
Expand Down Expand Up @@ -414,6 +419,8 @@ func (sql *SqliteDb) ImportMostRecentSnapshot(targetVersion int64, traverseOrder
return root, version, err
}

// FindDbsInPath finds all database directories in the given path that contain a changelog.sqlite file.
// This function is used by various commands to locate IAVL databases.
func FindDbsInPath(path string) ([]string, error) {
var paths []string
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
Expand All @@ -431,9 +438,6 @@ func FindDbsInPath(path string) ([]string, error) {
return paths, nil
}

// TODO
// merge these two functions

func (snap *sqliteSnapshot) writeStep(node *Node) error {
snap.ordinal++
// Pre-order, NLR traversal
Expand Down