Skip to content

Commit

Permalink
fix: adapt to changes on main after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Jul 26, 2023
1 parent 18b5bd9 commit 088f36e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
1 change: 0 additions & 1 deletion iroh-bytes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod get;
pub mod protocol;
pub mod provider;
pub mod util;
pub mod writable;

#[cfg(test)]
pub(crate) mod test_utils;
Expand Down
27 changes: 16 additions & 11 deletions iroh/examples/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async fn run(args: Args) -> anyhow::Result<()> {
println!("> storage directory: {storage_path:?}");

// create a runtime that can spawn tasks on a local-thread executors (to support !Send futures)
let rt = iroh::bytes::runtime::Handle::from_currrent(num_cpus::get())?;
let rt = iroh_bytes::util::runtime::Handle::from_currrent(num_cpus::get())?;

// create a blob store (with a iroh-bytes database inside)
let blobs = BlobStore::new(rt.clone(), storage_path.join("blobs"), endpoint.clone()).await?;
Expand Down Expand Up @@ -244,7 +244,12 @@ async fn run(args: Args) -> anyhow::Result<()> {
Ok(())
}

async fn handle_command(cmd: Cmd, doc: &Doc, ticket: &Ticket, log_filter: &LogLevelReload) -> anyhow::Result<()> {
async fn handle_command(
cmd: Cmd,
doc: &Doc,
ticket: &Ticket,
log_filter: &LogLevelReload,
) -> anyhow::Result<()> {
match cmd {
Cmd::Set { key, value } => {
doc.insert_bytes(&key, value.into_bytes().into()).await?;
Expand Down Expand Up @@ -516,7 +521,7 @@ fn derp_map_from_url(url: Url) -> anyhow::Result<DerpMap> {
DEFAULT_DERP_STUN_PORT,
UseIpv4::TryDns,
UseIpv6::TryDns,
0
0,
))
}

Expand All @@ -528,21 +533,21 @@ mod iroh_bytes_handlers {
use futures::{future::BoxFuture, FutureExt};
use iroh_bytes::{
protocol::{GetRequest, RequestToken},
provider::{
CustomGetHandler, Database, EventSender, IrohCollectionParser,
RequestAuthorizationHandler,
},
provider::{CustomGetHandler, EventSender, RequestAuthorizationHandler},
};

use iroh::{collection::IrohCollectionParser, database::flat::Database};

#[derive(Debug, Clone)]
pub struct IrohBytesHandlers {
db: Database,
rt: iroh_bytes::runtime::Handle,
rt: iroh_bytes::util::runtime::Handle,
event_sender: NoopEventSender,
get_handler: Arc<NoopCustomGetHandler>,
auth_handler: Arc<NoopRequestAuthorizationHandler>,
}
impl IrohBytesHandlers {
pub fn new(rt: iroh_bytes::runtime::Handle, db: Database) -> Self {
pub fn new(rt: iroh_bytes::util::runtime::Handle, db: Database) -> Self {
Self {
db,
rt,
Expand All @@ -569,8 +574,8 @@ mod iroh_bytes_handlers {
#[derive(Debug, Clone)]
struct NoopEventSender;
impl EventSender for NoopEventSender {
fn send(&self, _event: iroh_bytes::provider::Event) -> Option<iroh_bytes::provider::Event> {
None
fn send(&self, _event: iroh_bytes::provider::Event) -> BoxFuture<()> {
async {}.boxed()
}
}
#[derive(Debug)]
Expand Down
2 changes: 2 additions & 0 deletions iroh/src/database/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use crate::util::io::validate_bao;
use crate::util::io::BaoValidationError;
use crate::util::progress::{Progress, ProgressReader, ProgressReaderUpdate};

pub mod writable;

/// File name of directory inside `IROH_DATA_DIR` where outboards are stored.
const FNAME_OUTBOARDS: &str = "outboards";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ use iroh_io::{AsyncSliceWriter, File};
use range_collections::RangeSet2;
use tokio::io::AsyncRead;

use crate::{
use iroh_bytes::{
get::fsm,
protocol::{GetRequest, RangeSpecSeq, Request},
provider::{create_collection, DataSource, Database, DbEntry, FNAME_PATHS},
Hash,
};

use crate::database::flat::{create_collection, DataSource, Database, DbEntry, FNAME_PATHS};

/// A blob database into which new blobs can be inserted.
///
/// Blobs can be inserted either from bytes or by downloading from open connections to peers.
Expand Down
8 changes: 5 additions & 3 deletions iroh/src/sync/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use futures::{
stream::FuturesUnordered,
FutureExt,
};
use iroh_bytes::{provider::Database, util::Hash, writable::WritableFileDatabase};
use iroh_bytes::util::Hash;
use iroh_gossip::net::util::Dialer;
use iroh_io::{AsyncSliceReader, AsyncSliceReaderExt};
use iroh_net::{tls::PeerId, MagicEndpoint};
Expand All @@ -25,6 +25,8 @@ use tokio::{
use tokio_stream::StreamExt;
use tracing::{debug, error, warn};

use crate::database::flat::{writable::WritableFileDatabase, Database};

#[derive(Debug, Copy, Clone)]
pub enum DownloadMode {
Always,
Expand Down Expand Up @@ -187,7 +189,7 @@ pub struct BlobStore {
}
impl BlobStore {
pub async fn new(
rt: iroh_bytes::runtime::Handle,
rt: iroh_bytes::util::runtime::Handle,
data_path: PathBuf,
endpoint: MagicEndpoint,
) -> anyhow::Result<Self> {
Expand Down Expand Up @@ -263,7 +265,7 @@ pub struct Downloader {

impl Downloader {
pub fn new(
rt: iroh_bytes::runtime::Handle,
rt: iroh_bytes::util::runtime::Handle,
endpoint: MagicEndpoint,
blobs: WritableFileDatabase,
) -> Self {
Expand Down
3 changes: 2 additions & 1 deletion iroh/src/sync/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Actor {
// add addresses of initial peers to our endpoint address book
for peer in &initial_peers {
self.endpoint
.add_known_addrs(peer.peer_id, &peer.addrs)
.add_known_addrs(peer.peer_id, peer.derp_region, &peer.addrs)
.await?;
}

Expand Down Expand Up @@ -235,6 +235,7 @@ impl Actor {
self.endpoint
.add_known_addrs(peer.peer_id, peer.derp_region, &peer.addrs)
.await?;
}

// trigger initial sync with initial peers
for peer in peer_ids {
Expand Down

0 comments on commit 088f36e

Please sign in to comment.