Skip to content

Commit

Permalink
refactor(iroh,iroh-bytes): replace currrent with current (#1467)
Browse files Browse the repository at this point in the history
## Description

a typo

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [ ] Documentation updates if relevant.
- [ ] Tests if relevant.
  • Loading branch information
divagant-martian authored Sep 7, 2023
1 parent 1df9255 commit 4f4d8e5
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 14 deletions.
4 changes: 1 addition & 3 deletions iroh-bytes/src/util/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ impl Handle {

/// Create a new iroh runtime using the current tokio runtime as the main
/// runtime, and the given number of thread per core executors.
pub fn from_currrent(
size: usize,
) -> std::result::Result<Self, tokio::runtime::TryCurrentError> {
pub fn from_current(size: usize) -> std::result::Result<Self, tokio::runtime::TryCurrentError> {
Ok(Self::new(
tokio::runtime::Handle::try_current()?,
tokio_util::task::LocalPoolHandle::new(size),
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;
let db = iroh::baomap::mem::Store::new(rt.clone());
let store = iroh_sync::store::memory::Store::default();
let node = Node::builder(db.clone(), store)
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn main() -> anyhow::Result<()> {
let collection = Collection::new(blobs, 0)?;
let hash = db.insert(collection.to_bytes()?);
// create a new iroh runtime with 1 worker thread, reusing the existing tokio runtime
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;

// create an in-memory doc store for iroh sync (not used here)
let doc_store = iroh_sync::store::memory::Store::default();
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> {
// create an in-memory doc store (not used in the example)
let doc_store = iroh_sync::store::memory::Store::default();
// create a new iroh runtime with 1 worker thread, reusing the existing tokio runtime
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;
// add some data and remember the hash
let hash = db.insert(b"Hello, world!");
// create a new node
Expand Down
4 changes: 2 additions & 2 deletions iroh/examples/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn make_rpc_endpoint(

async fn run(db: impl Store) -> anyhow::Result<()> {
// create a new iroh runtime with 1 worker thread, reusing the existing tokio runtime
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;
// create a random secret key
let secret_key = SecretKey::generate();
// create a rpc endpoint
Expand Down Expand Up @@ -81,7 +81,7 @@ struct Args {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
setup_logging();
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;

let args = Args::parse();
match args.path {
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,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::util::runtime::Handle::from_currrent(num_cpus::get())?;
let rt = iroh_bytes::util::runtime::Handle::from_current(num_cpus::get())?;

// create a doc store for the iroh-sync docs
let author = Author::from_bytes(&secret_key.to_bytes());
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/commands/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl GetInteractive {
provider = provider.enable_derp(dm.clone());
}
let provider = provider
.runtime(&iroh_bytes::util::runtime::Handle::from_currrent(1)?)
.runtime(&iroh_bytes::util::runtime::Handle::from_current(1)?)
.spawn()
.await?;
let out = out_dir
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ mod tests {
/// Pick up the tokio runtime from the thread local and add a
/// thread per core runtime.
fn test_runtime() -> runtime::Handle {
runtime::Handle::from_currrent(1).unwrap()
runtime::Handle::from_current(1).unwrap()
}

#[tokio::test]
Expand All @@ -1444,7 +1444,7 @@ mod tests {
#[cfg(feature = "mem-db")]
#[tokio::test]
async fn test_node_add_collection_event() -> Result<()> {
let rt = runtime::Handle::from_currrent(1)?;
let rt = runtime::Handle::from_current(1)?;
let db = crate::baomap::mem::Store::new(rt);
let doc_store = iroh_sync::store::memory::Store::default();
let node = Node::builder(db, doc_store)
Expand Down
2 changes: 1 addition & 1 deletion iroh/tests/provide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use iroh_sync::store;
/// Pick up the tokio runtime from the thread local and add a
/// thread per core runtime.
fn test_runtime() -> runtime::Handle {
runtime::Handle::from_currrent(1).unwrap()
runtime::Handle::from_current(1).unwrap()
}

fn test_node<D: Store>(
Expand Down
2 changes: 1 addition & 1 deletion iroh/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use iroh_sync::store::{self, GetFilter};
/// Pick up the tokio runtime from the thread local and add a
/// thread per core runtime.
fn test_runtime() -> runtime::Handle {
runtime::Handle::from_currrent(1).unwrap()
runtime::Handle::from_current(1).unwrap()
}

fn test_node(
Expand Down

0 comments on commit 4f4d8e5

Please sign in to comment.