Skip to content
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

Remove db accesses in listpeerchannels #7679

Commits on Sep 19, 2024

  1. lightningd: move stats into struct channel.

    Like other fields, mirror them into the db.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    334767a View commit details
    Browse the repository at this point in the history
  2. listpeerchannels: use struct channel stats, don't fetch from db.

    This avoids a db lookup on every iteration of listpeerchannels, which
    can be slow on large nodes (Postgres, I assume).
    
    We can now simply add the fields we want to channel load, and remove
    wallet_channel_stats_load entirely.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    a9fc90f View commit details
    Browse the repository at this point in the history
  3. db: clean up channel_stats handling.

    Indirection via a string and an enum is just adding confusion here.
    
    And move the `struct channel_stats` into channel.h.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    64a03eb View commit details
    Browse the repository at this point in the history
  4. lightningd: move the state changes into struct channel.

    And instead of loading them in listpeerchannels, use them.  This means
    listpeerchannels no longer touches the db.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Fixed: JSONRPC: `listpeerchannels` (and thus, pay) sped up on very large nodes.
    rustyrussell committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    f94550d View commit details
    Browse the repository at this point in the history
  5. lightningd: rename state_change_entry to channel_state_change, and us…

    …e pointers.
    
    This name is clearer than the old one.
    
    And since the struct contains a string, it's more natural for the
    struct to be the tal parent of the string so it's a real object.  This means
    we need an array of pointers, so each struct can be its own tal object.
    
    wallet_state_change_get is hoisted higher in the code and made static.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    829fdab View commit details
    Browse the repository at this point in the history