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

Consider dropping error result from ImmutableTree.Export #755

Open
elias-orijtech opened this issue May 3, 2023 · 0 comments
Open

Consider dropping error result from ImmutableTree.Export #755

elias-orijtech opened this issue May 3, 2023 · 0 comments

Comments

@elias-orijtech
Copy link
Contributor

ImmutableTree.Export could be simplified to return no error.

Currently, it has two error cases:

iavl/export.go

Lines 41 to 47 in 64ffc27

if tree == nil {
return nil, fmt.Errorf("tree is nil: %w", ErrNotInitalizedTree)
}
// CV Prevent crash on incrVersionReaders if tree.ndb == nil
if tree.ndb == nil {
return nil, fmt.Errorf("tree.ndb is nil: %w", ErrNotInitalizedTree)
}

The first case, tree == nil, can be handled by (1) declaring the case a programmer error and accepting the panic or (2) by returning an *Exporter whose Next returns ErrorExportDone immediately.

The second case, tree.ndb == nil, signifies an in-memory database which doesn't warrant an error. Why not skip the call to tree.ndb.incrVersionReaders and proceed with the export?

CC @odeke-em

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant