Skip to content

feat: lwk esplora concurrency#501

Merged
michael1011 merged 2 commits into
feat/lwkfrom
feat/lwk-esplora-concurrency
Jul 11, 2025
Merged

feat: lwk esplora concurrency#501
michael1011 merged 2 commits into
feat/lwkfrom
feat/lwk-esplora-concurrency

Conversation

@jackstar12

@jackstar12 jackstar12 commented Jul 11, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Introduced a builder pattern for creating Esplora clients, allowing for more flexible configuration options.
  • Refactor

    • Streamlined the initialization of the Esplora client to use the new builder approach.
    • Unified log messaging related to Esplora client usage.
  • Chores

    • Updated the lwk subproject dependency to a newer version.

@coderabbitai

coderabbitai Bot commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A builder pattern for constructing an EsploraClient was introduced, with new struct and FFI converter logic in Go, corresponding C header declarations, and integration into the wallet backend initialization. The wallet's disconnect logic was simplified, and the Rust subproject reference was updated. No existing logic was modified outside these additions.

Changes

File(s) Change Summary
internal/onchain/liquid-wallet/lwk/lwk.go Added EsploraClientBuilder struct, FFI converters, destroyers, and EsploraClientFromBuilder function.
internal/onchain/liquid-wallet/lwk/lwk.h Declared new FFI constructor and checksum functions for EsploraClientFromBuilder.
internal/onchain/liquid-wallet/wallet.go Refactored Esplora client initialization to use the builder; simplified wallet disconnect logic.
lwk Updated Rust subproject reference to a new commit.

Sequence Diagram(s)

sequenceDiagram
    participant Wallet
    participant EsploraClientBuilder
    participant FFI
    participant EsploraClient

    Wallet->>EsploraClientBuilder: Create builder with params
    Wallet->>FFI: Call EsploraClientFromBuilder(builder)
    FFI->>EsploraClient: Construct EsploraClient via builder
    EsploraClient-->>FFI: Return instance or error
    FFI-->>Wallet: Return EsploraClient or error
Loading

Poem

A builder hops in, so clever and neat,
Esplora clients now build with a beat!
Old code refactored, connections made clear,
Wallets now simpler, less code to fear.
With every new struct, a rabbit’s delight—
Hopping through code, making it right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michael1011

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/onchain/liquid-wallet/wallet.go (1)

116-116: Consider making the concurrency value configurable.

The hard-coded concurrency value of 32 may not be optimal for all environments. Consider making this configurable through the EsploraConfig struct or environment variables to allow tuning based on system resources and network conditions.

type EsploraConfig struct {
	Url         string
	Waterfall   bool
+	Concurrency *uint32
}

Then use it in the builder:

-		concurrency := uint32(32)
+		concurrency := uint32(32)
+		if cfg.Esplora.Concurrency != nil {
+			concurrency = *cfg.Esplora.Concurrency
+		}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4852f12 and 3525fda.

📒 Files selected for processing (4)
  • internal/onchain/liquid-wallet/lwk/lwk.go (3 hunks)
  • internal/onchain/liquid-wallet/lwk/lwk.h (2 hunks)
  • internal/onchain/liquid-wallet/wallet.go (1 hunks)
  • lwk (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
internal/onchain/liquid-wallet/wallet.go (1)
Learnt from: jackstar12
PR: BoltzExchange/boltz-client#444
File: internal/rpcserver/router.go:2036-2052
Timestamp: 2025-05-26T09:32:25.533Z
Learning: In boltz-client, when handling Boltz backend connectivity during startup, the code intentionally uses different error handling strategies: logger.Fatalf for version incompatibility (fail fast approach) and retry logic for availability issues. Version incompatibility requires immediate human intervention and should not be retried.
🧬 Code Graph Analysis (1)
internal/onchain/liquid-wallet/wallet.go (2)
internal/logger/logger.go (1)
  • Infof (113-115)
internal/onchain/liquid-wallet/lwk/lwk.go (3)
  • EsploraClientFromBuilder (3196-3206)
  • EsploraClientBuilder (7307-7313)
  • Network (4070-4072)
🔇 Additional comments (9)
lwk (1)

1-1: API Compatibility Verified: No Remaining Old Constructor Usages

Ran a full-text scan for NewEsploraClient( and confirmed:

  • Definition only in the lwk submodule:
    • internal/onchain/liquid-wallet/lwk/lwk.go:3184
  • No external call-sites in the Go codebase.

Builder API is already in use where clients are constructed:
• internal/onchain/liquid-wallet/wallet.go:117

All call-sites have migrated to EsploraClientBuilder, so the submodule bump can be merged safely.

internal/onchain/liquid-wallet/wallet.go (3)

115-115: Log message unification looks good.

The unified log message appropriately indicates Esplora client usage without distinguishing waterfall mode, which aligns with the refactoring to use the builder pattern.


117-122: Builder pattern implementation looks correct.

The transition from conditional instantiation to the builder pattern is well-implemented. The builder parameters correctly map to the previous logic with appropriate field mappings.


124-124: Error message consistency improvement.

The updated error message format provides better consistency with the "esplora client:" prefix, making it easier to identify the source of configuration errors.

internal/onchain/liquid-wallet/lwk/lwk.h (2)

652-656: New FFI constructor looks correct

  • Guard macro follows existing naming scheme; avoids double-definition.
  • Parameter list (RustBuffer builder, RustCallStatus *out_status) is consistent with other builder-style constructors, so ownership semantics remain predictable.
  • No symbol collision with the originals ..._new / ..._new_waterfalls.

Nothing blocking here.


3064-3066: No Go-side registration required—checksum is already in the glue code

The newly added uniffi_lwk_checksum_constructor_esploraclient_from_builder is referenced in internal/onchain/liquid-wallet/lwk/lwk.go (lines 1775–1780), verifying its checksum (10195) via the existing rustCall pattern. No further updates to Go glue are necessary.

internal/onchain/liquid-wallet/lwk/lwk.go (3)

1774-1782: LGTM: Checksum verification follows established pattern.

The checksum verification for the new constructor function correctly follows the existing pattern in the codebase. The hardcoded checksum value (10195) should match the Rust side implementation.


3196-3206: LGTM: Constructor function properly handles FFI and errors.

The EsploraClientFromBuilder function correctly:

  • Uses the established rustCallWithError pattern for error handling
  • Properly converts between Go and Rust types using FFI converters
  • Returns appropriate error values on failure
  • Follows the naming conventions of the codebase

7307-7358: LGTM: Builder struct and FFI converters are well-implemented.

The EsploraClientBuilder struct and its associated FFI converter methods are correctly implemented:

  • Optional fields (Concurrency and Timeout) are properly handled as pointers
  • The Destroy() method correctly calls destroy on all fields for proper memory management
  • FFI converter methods (Lift, Read, Lower, Write) follow the established UniFFI patterns
  • Public field naming follows Go conventions
  • The implementation is consistent with other FFI converters in the codebase

@michael1011 michael1011 merged commit 77953a3 into feat/lwk Jul 11, 2025
2 of 3 checks passed
@michael1011 michael1011 deleted the feat/lwk-esplora-concurrency branch July 11, 2025 11:07
@jackstar12 jackstar12 mentioned this pull request Jul 11, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Mar 19, 2026
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