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

feat: complete Service client implementation #17

Open
Rjected opened this issue Sep 7, 2022 · 0 comments
Open

feat: complete Service client implementation #17

Rjected opened this issue Sep 7, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Rjected
Copy link
Owner

Rjected commented Sep 7, 2022

Currently service.rs contains a mostly unimplemented Service on the server side. The tower Service abstraction is convenient for both clients and servers, so a client should be easy to implement for a single peer.

Once implemented, dialing a node should look something like this:

let mut peer = make_client(peer_addr).await.unwrap();

The client should also make p2p requests more ergonomic. For example rather than dealing with peer message channels directly, we should have the following UX for making requests:

// using From<Vec<[u8; 32]>> for GetPooledTransactions
let txs_request: GetPooledTransactions = vec![
    hex!("c05a9eda51dd448c79e1dda1c79a3835c82c1142104f88adc1a64ec80fd193fb"),
    hex!("2fa4c5912523f735581cc731a9d44870fbb45cc3cbfb529d643b5aaca112beda"),
    hex!("3f855459086213a3def40270ee1c6e12aba7f5f81375ca35cdcd8e71e7a9b092"),
].into();

// a lower-level way to make a request, using the `Service` trait, still not bad
let request = Request::GetPooledTransactions(
    RequestPair {
        request_id: 1,
        message: txs_request,
    }
);
let response = peer.call(request).await.unwrap();

// another possible way to make a request
// if using the `Service` under the hood the implementation of this method should be very easy
let txs_response = peer.get_pooled_transactions(txs_request).await.unwrap();
@Rjected Rjected added the enhancement New feature or request label Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant