Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
2nd leveldb database instance removal #168
2nd leveldb database instance removal #168
Changes from 1 commit
51dea59
98bec50
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this cause us some issues? IMO it would be better if we would follow a null object pattern and therefore create the
NoOpDatabase
implementation, that would implement the following interface:...and eliminate the nil checks in the
storagev2/storage.go
. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some indication do we have 2 instances or one. If we have only one, then we should always default to index 0 for all read/write operations. So if the 2nd element of array is nil then we know we should pickup db instance with index 0. With this dummy interface implementation we can't accomplish that
Method doing database mapping:
func (s *Storage) getDB(t uint8) Database {
i := getIndex(t)
if s.db[i] != nil {
return s.db[i]
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But again, instead of checking if it is nil, you can check whether the concrete type is the
NoOpDatabase
.But in the other places, it would be safe to invoke the function against the instance (and remove the nil checks), because it would not be
nil
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but that way we will not know if we are calling a bad instance or a good one. In my opinion it is better to crash then to call interface doing nothing. But anyway it will never happen to call a nil instance because all calls must go through this getDB mapper first.