Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a hight level api for freenet-core #1031

Open
gogo2464 opened this issue Apr 6, 2024 · 4 comments · May be fixed by #1032
Open

create a hight level api for freenet-core #1031

gogo2464 opened this issue Apr 6, 2024 · 4 comments · May be fixed by #1032

Comments

@gogo2464
Copy link
Contributor

gogo2464 commented Apr 6, 2024

it is currently complicated to do GET/UPDATE/SUBSCRIBE requests in freenet library.

For example, fdev had to reimplement everything https://github.com/freenet/freenet-core/blob/main/crates/fdev/src/main.rs#L58

I suggest to exposed a struct to do:

  • request.get
  • request.update
  • request.subscribe
  • etc...

I could put it in the lib.rs file https://github.com/freenet/freenet-stdlib/blob/main/rust/src/lib.rs

@gogo2464 gogo2464 linked a pull request Apr 6, 2024 that will close this issue
@sanity
Copy link
Collaborator

sanity commented Apr 6, 2024

I think it belongs in the client_api module, perhaps for now in a client_api.simple module.

So something like:

let api = client_api.simple.API::new(ws_port);
let contract_state : Vec<u8> = api.get(contract_address).await;

Would appreciate @iduartgomez's input also.

@gogo2464
Copy link
Contributor Author

gogo2464 commented Apr 7, 2024

I started to implement it.

I love the concept of exposing minimal api. The issue is it sounds a windows driver wrapper philosophy. We should expose only the required and let everything else in private.

We may let folders as

  • internal
    • everything
  • external
    • API
      • update
      • get

@gogo2464
Copy link
Contributor Author

I suggest for a final version to do:

  • freenet
    • everything
    • lib.rs
    • API
      • update
      • get

At this moment we may merge my current pr. Ready for a review.

@gogo2464
Copy link
Contributor Author

already usable with:

use freenet::client_api::simple::API;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let mut api = API::new(50509);
    let out = api.update(String::from("lftMopswnMBotiZflwjYvuGCWbsileTEruGllHmLnOAWp"), vec![1, 2, 3]).await;
}

the value of out should be Ok().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants