Skip to content

[sql-9] sessions: small sql preparations #967

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

Merged
merged 5 commits into from
Feb 11, 2025

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Feb 9, 2025

This is a pure refactor that just does a bit of code-move and variable re-naming in preparation for adding sql variations of things.
We also make sure to use the session.Store interface in the code-base instead of the raw DB pointer.

Part of #966

In preparation for adding a new `sql_store.go` file later on.
Keep all KVDB logic contained within the same file.
To better reflect the DB backing the CRUD and to prepare for a new
`SQLStore` type.
And move an error here which we plan to use across DB types.
@ellemouton ellemouton self-assigned this Feb 9, 2025
@ellemouton ellemouton added the no-changelog This PR is does not require a release notes entry label Feb 9, 2025
@ellemouton ellemouton changed the title [Sql-9] sessions: small sql preparations [sql-9] sessions: small sql preparations Feb 9, 2025
@ellemouton ellemouton assigned jamaljsr and unassigned jamaljsr Feb 10, 2025
@ellemouton ellemouton requested a review from jamaljsr February 10, 2025 15:36
Copy link
Member

@jamaljsr jamaljsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks great 👌. I was able to compile & run litd on regtest with no issues. I also confirmed the unit tests passed.

Regarding the code, the refactors seem pretty straight-forward. I'm still getting familiar with the codebase, so don't have any implementation specific feedback just yet.

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀! Leaving a comment regarding one nil check that'd be needed with this refactor, but other than that, this looks good to go 🔥

terminal.go Outdated
@@ -1457,6 +1457,11 @@ func (g *LightningTerminal) shutdownSubServers() error {
}
}

if err := g.sessionDB.Close(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also check that g.sessionDB != nil, incase g.start errors before setting the sessionDB field.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def - good catch 🙏

Give the sessionRpcServer access to the session store via the
session.Store interface instead of the raw DB pointer. This will make it
possible to swop out the implementation (which is currently bbolt) with
something else such as a SQL implementation. We move the responsibility
of closing the DB to the main LiT server.
Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀🎉

@ellemouton ellemouton merged commit 290344f into lightninglabs:master Feb 11, 2025
17 checks passed
@ellemouton ellemouton deleted the sql9Sessions1 branch February 11, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This PR is does not require a release notes entry sql-ize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants