Skip to content

db: implement sql tables and store for channel events#236

Merged
bitromortac merged 3 commits intolightninglabs:faraday-forwarding-abilityfrom
bitromortac:2603-fwd-prep-7
Apr 2, 2026
Merged

db: implement sql tables and store for channel events#236
bitromortac merged 3 commits intolightninglabs:faraday-forwarding-abilityfrom
bitromortac:2603-fwd-prep-7

Conversation

@bitromortac
Copy link
Copy Markdown
Contributor

Based on #235.

Implements tables to store channel events. Events can either be records of channels becoming on/offline, or updates of channel balances.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new database layer to track channel-related events, such as balance updates and connectivity status. It sets up the necessary SQL schema, migrations, and Go data access objects to store and retrieve this information, while also enhancing the project's testing infrastructure to support both SQLite and Postgres.

Highlights

  • Database Schema Implementation: Added SQL tables and migrations for tracking peers, channels, and channel events, including balance updates and online/offline status.
  • Data Access Layer: Implemented a new chanevents package providing a Store interface for interacting with the database, utilizing sqlc for type-safe query generation.
  • Testing Infrastructure: Introduced comprehensive test helpers for both SQLite and Postgres backends to facilitate robust database testing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/main.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the chanevents package, which provides functionality for monitoring and persisting channel events such as online/offline status and balance updates. The implementation includes a database Store with support for both SQLite and PostgreSQL backends, utilizing sqlc for type-safe query generation. Feedback primarily focuses on resolving inconsistencies between the SQL migration files and the generation script regarding the use of BIGINT for primary keys to match Go's int64. Additionally, there are suggestions to improve test configurability and to align the database check constraints with the application's EventType definitions.

Copy link
Copy Markdown
Contributor

@ViktorT-11 ViktorT-11 left a comment

Choose a reason for hiding this comment

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

Looks great, just leaving a few suggestions 🔥!

Comment on lines +75 to +78
require.NoError(t, err)
require.Equal(t, testChanPoint1, dbChannel.ChannelPoint)
require.Equal(t, testShortChanID1, dbChannel.ShortChannelID)
require.Equal(t, peerID, dbChannel.PeerID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could potentially create a channel comparison helper function instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I skipped this, should we do more comparisons I'll add it, also for events.

Copy link
Copy Markdown
Contributor

@ViktorT-11 ViktorT-11 left a comment

Choose a reason for hiding this comment

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

Nice! LGTM 🔥!

@bitromortac bitromortac merged commit 0af6417 into lightninglabs:faraday-forwarding-ability Apr 2, 2026
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants