-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
channeldb: isolate migrations #3633
Conversation
This commit is a direct copy of the complete channeldb package. It only changes the package declaration at the top of every file. We make this full copy so that review can be focused on the actual changes made. Otherwise changes may drown in all the file moves. Linting for the new package is disabled, as it contains lots of pre-existing issues.
This commit removes the migrations from channeldb and references those in the migrations_01_to_11 package. This creates a one-way dependency on the migrations. Future changes to channeldb won't be able to break migrations anymore.
a63de58
to
eb870ce
Compare
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.
Seems like this diff can be much smaller (only copy the essentials).
|
||
// TestChannelCache checks the behavior of the channelCache with respect to | ||
// insertion, eviction, and removal of cache entries. | ||
func TestChannelCache(t *testing.T) { |
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.
Do we really need to copy over all the tests as well? Can't we just copy the call graph of any encode/decode functions used in the migration.
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.
Previously I found that I needed some test code because it was reused. Left all of it in, but I think that also had a lot of deps that prevents more removal of code. Will look at the diff again.
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.
Ok, removed many more lines. Down to 5k lines now.
I used staticcheck
from https://github.com/dominikh/go-tools with the -unused.whole-program
flag to find more unused code.
eb870ce
to
5048fd5
Compare
8114062
to
838ffb0
Compare
Unit tests failing. Even by only removing code, I seem to have broken something. Will investigate. |
838ffb0
to
fbfc3c2
Compare
Test fixed. Problem was only an uninitialized logger. Not something magical triggered by code removal. Ready for review again. |
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.
not pretty, but I think it works. LGTM 🐸
@@ -48,12 +48,6 @@ type UnknownElementType struct { | |||
element interface{} | |||
} | |||
|
|||
// NewUnknownElementType creates a new UnknownElementType error from the passed | |||
// method name and element. | |||
func NewUnknownElementType(method string, el interface{}) UnknownElementType { |
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.
ok, guess the code is removed here.
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.
Not sure what this refers to. Probably you reviewed a previous version of the pr?
2f8e88f
to
a29bdce
Compare
a29bdce
to
60503d6
Compare
channeldb/migration_01_to_11/meta.go
Outdated
|
||
// FetchMeta fetches the meta data from boltdb and returns filled meta | ||
// structure. | ||
func (d *DB) FetchMeta(tx *bbolt.Tx) (*Meta, error) { |
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.
Is this code used by anything now?
Also I wouldn't mind removing tests, since they could depend on code that otherwise could be deleted.
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.
The code is used to do syncVersion
for migration tests. But that isn't really necessary to test every time. Added a commit that removes it.
Non-migration tests are all removed (afaik), the _test.go
files that remain just contain some vars and helpers that are used in the migration tests.
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.
Latest version LGTM
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.
LGTM 💎
Fixes #3628