Skip to content

Commit

Permalink
Run rustfmt.
Browse files Browse the repository at this point in the history
dvc94ch committed Mar 10, 2021
1 parent 12a0ae5 commit 98b0ec8
Showing 3 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions examples/compat.rs
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@ use ipfs_embed::{Config, Ipfs, Multiaddr, PeerId};
use libipld::{store::StoreParams, Cid, IpldCodec};

#[derive(Debug, Clone)]
struct SP;
struct Sp;

impl StoreParams for SP {
impl StoreParams for Sp {
type Hashes = libipld::multihash::Code;
type Codecs = IpldCodec;
const MAX_BLOCK_SIZE: usize = 1024 * 1024 * 4;
@@ -21,7 +21,7 @@ fn tracing_try_init() {
async fn main() -> anyhow::Result<()> {
tracing_try_init();
let config = Config::new(None, 1024 * 1024);
let ipfs = Ipfs::<SP>::new(config).await?;
let ipfs = Ipfs::<Sp>::new(config).await?;
let peer: PeerId = "QmRSGx67Kq8w7xSBDia7hQfbfuvauMQGgxcwSWw976x4BS".parse()?;
let addr: Multiaddr = "/ip4/54.173.33.96/tcp/4001".parse()?;
ipfs.dial_address(&peer, addr)?;
29 changes: 15 additions & 14 deletions src/db.rs
Original file line number Diff line number Diff line change
@@ -110,21 +110,22 @@ where
let gc_interval = config.gc_interval;
let gc_min_blocks = config.gc_min_blocks;
let gc_target_duration = config.gc_target_duration;
let gc_task = async_global_executor::spawn(async_global_executor::spawn_blocking(move || {
std::thread::sleep(gc_interval / 2);
loop {
tracing::debug!("gc_loop running incremental gc");
gc.lock()
.incremental_gc(gc_min_blocks, gc_target_duration)
.ok();
let gc_task =
async_global_executor::spawn(async_global_executor::spawn_blocking(move || {
std::thread::sleep(gc_interval / 2);
tracing::debug!("gc_loop running incremental delete orphaned");
gc.lock()
.incremental_delete_orphaned(gc_min_blocks, gc_target_duration)
.ok();
std::thread::sleep(gc_interval / 2);
}
}));
loop {
tracing::debug!("gc_loop running incremental gc");
gc.lock()
.incremental_gc(gc_min_blocks, gc_target_duration)
.ok();
std::thread::sleep(gc_interval / 2);
tracing::debug!("gc_loop running incremental delete orphaned");
gc.lock()
.incremental_delete_orphaned(gc_min_blocks, gc_target_duration)
.ok();
std::thread::sleep(gc_interval / 2);
}
}));
Ok(Self {
_marker: PhantomData,
gc_target_duration: config.gc_target_duration,
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -109,7 +109,11 @@ where
network2.unprovide(cid);
}
});
Ok(Self { storage, network, _event_task: Arc::new(event_task) })
Ok(Self {
storage,
network,
_event_task: Arc::new(event_task),
})
}

/// Returns the local `PeerId`.

0 comments on commit 98b0ec8

Please sign in to comment.