diff --git a/src/hb.rs b/src/hb.rs index 7fcf7de..93f7c40 100644 --- a/src/hb.rs +++ b/src/hb.rs @@ -2,7 +2,7 @@ use std::{fmt::Debug, path::Path, sync::Arc}; use derive_builder::Builder; use futures_lite::{AsyncRead, AsyncWrite, Stream}; -use hypercore::{AppendOutcome, Hypercore}; +use hypercore::{AppendOutcome, SharedCore}; use tokio::sync::RwLock; use crate::{ @@ -33,8 +33,7 @@ impl Hyperbee { stream: S, is_initiator: bool, ) -> Result<(), HyperbeeError> { - self - .tree + self.tree .read() .await .add_stream(stream, is_initiator) @@ -158,7 +157,7 @@ impl Hyperbee { } /// Helper for creating a [`Hyperbee`] from a [`Hypercore`] - pub fn from_hypercore(hypercore: Hypercore) -> Result { + pub fn from_hypercore>(hypercore: T) -> Result { Self::from_tree(Tree::from_hypercore(hypercore)?) } diff --git a/src/tree.rs b/src/tree.rs index 0aefc20..aba4ed9 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,6 +1,6 @@ use derive_builder::Builder; use futures_lite::{AsyncRead, AsyncWrite, Stream, StreamExt}; -use hypercore::{AppendOutcome, Hypercore, HypercoreBuilder, SharedCore, Storage}; +use hypercore::{AppendOutcome, HypercoreBuilder, SharedCore, Storage}; use prost::Message; use crate::{ @@ -34,8 +34,7 @@ impl Tree { stream: S, is_initiator: bool, ) -> Result<(), HyperbeeError> { - self - .blocks + self.blocks .read() .await .add_stream(stream, is_initiator) @@ -178,10 +177,8 @@ impl Tree { Self::from_blocks(blocks) } - pub fn from_hypercore(hypercore: Hypercore) -> Result { - let blocks = BlocksBuilder::default() - .core(SharedCore::from_hypercore(hypercore)) - .build()?; + pub fn from_hypercore>(hypercore: T) -> Result { + let blocks = BlocksBuilder::default().core(hypercore.into()).build()?; Self::from_blocks(blocks) }