Skip to content

Commit bacd68f

Browse files
committed
fixup! feat: support chain sourcing via REST interface
1 parent 657308e commit bacd68f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/builder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,7 @@ impl ArcedNodeBuilder {
767767
/// Configures the [`Node`] instance to connect to a Bitcoin Core node via RPC.
768768
///
769769
/// This method establishes an RPC connection that enables all essential chain operations including
770-
/// transaction broadcasting and chain data synchronization. RPC is the minimum required configuration
771-
/// for Bitcoin Core chain interactions and must be set up before any other Bitcoin Core connection options.
770+
/// transaction broadcasting and chain data synchronization.
772771
///
773772
/// ## Parameters:
774773
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
@@ -786,13 +785,13 @@ impl ArcedNodeBuilder {
786785

787786
/// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST endpoint.
788787
///
789-
/// This method enables chain data synchronization via Bitcoin Core's REST interface.
790-
/// It must be called after [`set_chain_source_bitcoind_rpc`] because REST is used only for chain
791-
/// synchronization, while RPC is still required for other essential operations like transaction
792-
/// broadcasting.
788+
/// This method enables chain data synchronization via Bitcoin Core's REST interface. We pass
789+
/// additional RPC configuration to non-REST-supported API calls like transaction broadcasting.
793790
///
794791
/// ## Parameters:
795792
/// * `rest_host`, `rest_port` - Required parameters for the Bitcoin Core REST connection.
793+
/// * `rpc_host`, `rpc_port`, `rpc_user`, `rpc_password` - Required parameters for the Bitcoin Core RPC
794+
/// connection
796795
pub fn set_chain_source_bitcoind_rest(
797796
&self, rest_host: String, rest_port: u16, rpc_host: String, rpc_port: u16,
798797
rpc_user: String, rpc_password: String,

src/chain/bitcoind.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use lightning_block_sync::http::{HttpEndpoint, JsonResponse};
1616
use lightning_block_sync::poll::ValidatedBlockHeader;
1717
use lightning_block_sync::rest::RestClient;
1818
use lightning_block_sync::rpc::{RpcClient, RpcError};
19-
use lightning_block_sync::{BlockSource, Cache};
19+
use lightning_block_sync::{
20+
AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource, Cache,
21+
};
2022

2123
use serde::Serialize;
2224

@@ -573,7 +575,7 @@ impl BitcoindClient {
573575
impl BlockSource for BitcoindClient {
574576
fn get_header<'a>(
575577
&'a self, header_hash: &'a bitcoin::BlockHash, height_hint: Option<u32>,
576-
) -> lightning_block_sync::AsyncBlockSourceResult<'a, lightning_block_sync::BlockHeaderData> {
578+
) -> AsyncBlockSourceResult<'a, BlockHeaderData> {
577579
match self {
578580
BitcoindClient::Rpc { rpc_client, .. } => {
579581
Box::pin(async move { rpc_client.get_header(header_hash, height_hint).await })
@@ -586,7 +588,7 @@ impl BlockSource for BitcoindClient {
586588

587589
fn get_block<'a>(
588590
&'a self, header_hash: &'a bitcoin::BlockHash,
589-
) -> lightning_block_sync::AsyncBlockSourceResult<'a, lightning_block_sync::BlockData> {
591+
) -> AsyncBlockSourceResult<'a, BlockData> {
590592
match self {
591593
BitcoindClient::Rpc { rpc_client, .. } => {
592594
Box::pin(async move { rpc_client.get_block(header_hash).await })
@@ -597,9 +599,7 @@ impl BlockSource for BitcoindClient {
597599
}
598600
}
599601

600-
fn get_best_block(
601-
&self,
602-
) -> lightning_block_sync::AsyncBlockSourceResult<(bitcoin::BlockHash, Option<u32>)> {
602+
fn get_best_block(&self) -> AsyncBlockSourceResult<(bitcoin::BlockHash, Option<u32>)> {
603603
match self {
604604
BitcoindClient::Rpc { rpc_client, .. } => {
605605
Box::pin(async move { rpc_client.get_best_block().await })

0 commit comments

Comments
 (0)