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

Add initial api for SDK #2

Merged
merged 3 commits into from Oct 10, 2022
Merged

Add initial api for SDK #2

merged 3 commits into from Oct 10, 2022

Conversation

i1i1
Copy link
Contributor

@i1i1 i1i1 commented Sep 18, 2022

This pr adds mock API for SDK, which exposes same functionality as this typescript example. Overall, it follows those rules:

  • Everything should be extendable
    • all the enums and public structures (which expose fields) are not exhaustive
    • most of the structures implement default
    • structures are constructed using builder pattern (look at the Node and Farmer)
    • most methods/functions/callbacks are async, so that if we don't need async functionality now, we could use that in future
  • Stateless
    • There is no reading/writing to a config file, as this kind of state management should be done at the different level (maybe subspace cli)

The simplest example of running both node and farmer would look like this:

let mut node = Noder::builder().build(Directory::Tmp).await.unwrap();
node.sync().await;

let mut farmer = Farmer::builder()
    .build(
        PublicKey::from(0; 32]),
        node,
        PlotDescription::with_tempdir(ByteSize::gb(10)),
    )
    .await
    .unwrap();
farmer.sync().await;
farmer.start_farming().await;
loop {}

@i1i1 i1i1 requested a review from rg3l3dr September 18, 2022 19:26
@nazar-pc
Copy link
Member

I don't think I'm a good person to review this, I'm 100% out of context on what this is supposed to do and what the goals are.

src/node.rs Show resolved Hide resolved
src/farmer.rs Outdated Show resolved Hide resolved
ozgunozerk
ozgunozerk previously approved these changes Oct 5, 2022
Copy link
Contributor

@ozgunozerk ozgunozerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@achiurizo achiurizo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock this. Let's make incremental fixes as reviews come in so that we can start moving forward on SDK 🙏

@i1i1 i1i1 merged commit 8b406b2 into master Oct 10, 2022
@i1i1 i1i1 deleted the initial-api branch October 10, 2022 20:19
i1i1 added a commit that referenced this pull request Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants