Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
add sdk as workspace member
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthDesai committed Jan 29, 2024
1 parent 426c0e9 commit 18c46dd
Show file tree
Hide file tree
Showing 42 changed files with 7,349 additions and 8 deletions.
187 changes: 180 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"pulsar",
"sdk/*"
]

# The list of dependencies below (which can be both direct and indirect dependencies) are crates
Expand Down
2 changes: 1 addition & 1 deletion pulsar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ single-instance = "0.3.3"
sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", features = ["full_crypto"] }
strum = "0.24.1"
strum_macros = "0.24.3"
subspace-sdk = { git = "https://github.com/subspace/subspace-sdk", rev = "000c6c774f3dd995e783d6d78d1d59669540b454", default-features = false }
subspace-sdk = { path = "../sdk/subspace-sdk", default-features = false }
thiserror = "1"
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread", "tracing", "signal"] }
toml = "0.7"
Expand Down
49 changes: 49 additions & 0 deletions sdk/README.md
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;
```
24 changes: 24 additions & 0 deletions sdk/dsn/Cargo.toml
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"
Loading

0 comments on commit 18c46dd

Please sign in to comment.