Update README.
This commit is contained in:
parent
8ffa13c7c5
commit
e64cf71fe4
27
README.md
27
README.md
@ -1,27 +1,32 @@
|
|||||||
# Rust IPFS implementation
|
# Rust IPFS implementation
|
||||||
Currently implements an altruistic bitswap strategy over mdns.
|
Currently implements an altruistic bitswap strategy over mdns.
|
||||||
|
|
||||||
## Known issues
|
|
||||||
* The mdns implementation of `go-ipfs` and `js-ipfs` aren't compatible with `rust-libp2p`.
|
|
||||||
* Locating providers via kademlia dht doesn't work.
|
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
```rust
|
```rust
|
||||||
|
#![feature(async_await, await_macro, futures_api)]
|
||||||
|
use futures::future::FutureObj;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use ipfs::{Block, Ipfs, IpfsOptions};
|
use ipfs::{Block, Ipfs, IpfsOptions, Types};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = IpfsOptions::new();
|
let options = IpfsOptions::new();
|
||||||
env_logger::Builder::new().parse(&options.ipfs_log).init();
|
env_logger::Builder::new().parse(&options.ipfs_log).init();
|
||||||
let mut ipfs = Ipfs::new(options);
|
let mut ipfs = Ipfs::<Types>::new(options);
|
||||||
let block = Block::from("hello block2\n");
|
let block = Block::from("hello block2\n");
|
||||||
ipfs.put_block(block);
|
|
||||||
let cid = Block::from("hello block\n").cid();
|
let cid = Block::from("hello block\n").cid();
|
||||||
let future = ipfs.get_block(cid).map(|block| {
|
|
||||||
println!("Received block with contents: '{}'",
|
tokio::run(FutureObj::new(Box::new(async move {
|
||||||
|
tokio::spawn(ipfs.start_daemon().compat());
|
||||||
|
await!(ipfs.init_repo()).unwrap();
|
||||||
|
await!(ipfs.open_repo()).unwrap();
|
||||||
|
|
||||||
|
await!(ipfs.put_block(block)).unwrap();
|
||||||
|
let block = await!(ipfs.get_block(cid.clone())).unwrap();
|
||||||
|
println!("Received block with contents: {:?}",
|
||||||
String::from_utf8_lossy(&block.data()));
|
String::from_utf8_lossy(&block.data()));
|
||||||
});
|
|
||||||
tokio::run(ipfs.join(future).map(|_| ()));
|
Ok(())
|
||||||
|
})).compat());
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user