-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add json columns in Postgres (#1865)
A json column has been added to the few tables that contains an opaque serialized blob: - `local_channels.data` - `nodes.data` - `channels.channel_announcement`, `channels.channel_update_x` We can now access all the individual data fields from SQL. For the serialization, we use the same serializers than the one that were previously used by the API. They have been moved to the `eclair-core` module and simplified a bit. There are two json data types in Postgres: `JSON` and `JSONB`. We use the latter one, which is more recent, and allows indexing. An alternative to this PR would have been to use columns, but: - there would have been a *lot* of columns for the channel data - every modification of our types would have required a db migration NB: to handle non-backwards compatible changes in the json serializersi, all the json columns can be recomputed on restart by setting `eclair.db.reset-json-columns=true`. Change in in ChannelCodecsSpec: The goal of this test is to make sure that, in addition to successfully decoding data that encoded with an older codec, we actually read the correct data. Just because there is no error doesn't mean that we interpreted the data properly. For example we could invert a `payment_hash` and a `payment_preimage`. We can't compare object to object, because the current version of the class has probably changed too. That's why we compare using the json representation of the data, that we amend to ignore new or modified fields. After doing a manual comparison, I updated the test to use the current json serializers, and replaced the test data with the latest json serialization. This allows us to remove all the tweaks that we added over time to take into account new and updated fields.
- Loading branch information
Showing
13 changed files
with
651 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.