This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d776e98
commit 6496b80
Showing
42 changed files
with
7,349 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Subspace-SDK | ||
|
||
<!--- TODO: Add docs-rs label (should we generate and host our own one?) ---> | ||
|
||
A library for easily running a local Subspace node and/or farmer. | ||
|
||
## Dependencies | ||
|
||
You'll have to have [Rust toolchain](https://rustup.rs/) installed as well as some packages in addition (Ubuntu example): | ||
```bash | ||
sudo apt-get install build-essential llvm protobuf-compiler | ||
``` | ||
|
||
## Simplest example | ||
|
||
Start a node and farmer and wait for 10 blocks being farmed. | ||
|
||
```rust | ||
use futures::prelude::*; | ||
|
||
let node = subspace_sdk::Node::builder() | ||
.force_authoring(true) | ||
.role(subspace_sdk::node::Role::Authority) | ||
// Starting a new chain | ||
.build("node", subspace_sdk::chain_spec::dev_config().unwrap()) | ||
.await | ||
.unwrap(); | ||
|
||
let plots = [subspace_sdk::PlotDescription::new("plot", bytesize::ByteSize::mb(100)).unwrap()]; | ||
let cache = subspace_sdk::farmer::CacheDescription::new("cache", bytesize::ByteSize::mb(10)).unwrap(); | ||
let farmer = subspace_sdk::Farmer::builder() | ||
.build(subspace_sdk::PublicKey::from([0; 32]), node.clone(), &plots, cache) | ||
.await | ||
.expect("Failed to init a farmer"); | ||
|
||
for plot in farmer.iter_plots().await { | ||
let mut plotting_progress = plot.subscribe_initial_plotting_progress().await; | ||
while plotting_progress.next().await.is_some() {} | ||
} | ||
tracing::info!("Initial plotting completed"); | ||
|
||
node.subscribe_new_blocks() | ||
.await | ||
.unwrap() | ||
// Wait 10 blocks and exit | ||
.take(10) | ||
.for_each(|block| async move { tracing::info!(?block, "New block!") }) | ||
.await; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "sdk-dsn" | ||
version = "0.1.0" | ||
edition = "2021" | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
derivative = "2.2.0" | ||
derive_builder = "0.12" | ||
derive_more = "0.99" | ||
futures = "0.3" | ||
hex = "0.4.3" | ||
parking_lot = "0.12" | ||
prometheus-client = "0.22.0" | ||
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } | ||
sc-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "bd435100200b3dcce6d6f50534d52e3cd039ca8e" } | ||
sdk-utils = { path = "../utils" } | ||
serde = { version = "1", features = ["derive"] } | ||
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } | ||
sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } | ||
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "bd435100200b3dcce6d6f50534d52e3cd039ca8e", default-features = false } | ||
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "bd435100200b3dcce6d6f50534d52e3cd039ca8e" } | ||
tracing = "0.1" |
Oops, something went wrong.