Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Dec 5, 2024
1 parent 3fce070 commit ff66ea4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 1 addition & 10 deletions node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,7 @@ where
S: Store,
{
/// Creates and starts a new celestia node with a given config.
async fn new(config: NodeConfig<B, S>) -> Result<Self> {
let (node, _) = Node::new_subscribed(config).await?;
Ok(node)
}

/// Creates and starts a new celestia node with a given config.
///
/// Returns `Node` alogn with `EventSubscriber`. Use this to avoid missing any
/// events that will be generated on the construction of the node.
async fn new_subscribed(config: NodeConfig<B, S>) -> Result<(Self, EventSubscriber)> {
async fn start(config: NodeConfig<B, S>) -> Result<(Self, EventSubscriber)> {
let event_channel = EventChannel::new();
let event_sub = event_channel.subscribe();
let store = Arc::new(config.store);
Expand Down
6 changes: 3 additions & 3 deletions node/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ where
{
/// Creates and starts a new Celestia [`Node`].
pub async fn start(self) -> Result<Node<B, S>> {
let config = self.build_config()?;
Node::new(config).await
let (node, _) = self.start_subscribed().await?;
Ok(node)
}

/// Creates and starts a new Celestia [`Node`].
Expand All @@ -69,7 +69,7 @@ where
/// any events that will be generated on the construction of the node.
pub async fn start_subscribed(self) -> Result<(Node<B, S>, EventSubscriber)> {
let config = self.build_config()?;
Node::new_subscribed(config).await
Node::start(config).await
}

/// Set the [`Blockstore`] for Bitswap.
Expand Down

0 comments on commit ff66ea4

Please sign in to comment.