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

Mempool add APIs #489

Merged
merged 29 commits into from
Nov 1, 2023
Merged

Mempool add APIs #489

merged 29 commits into from
Nov 1, 2023

Conversation

al8n
Copy link
Contributor

@al8n al8n commented Oct 30, 2023

No description provided.

@al8n al8n added the enhancement New feature or request label Oct 30, 2023
@al8n al8n added this to the Nomos testnet (playground) milestone Oct 30, 2023
@al8n al8n self-assigned this Oct 30, 2023
@danielSanchezQ danielSanchezQ changed the title finish mempool add apis Mempool add APIs Oct 30, 2023
post,
path = "/mempool/add/tx",
responses(
(status = 200, description = "add transaction to the mempool"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to be consistent in descriptions. I have seen usually we capitalize them. Tiny details.

Comment on lines +100 to +101
.route("/mempool/add/tx", routing::post(add_tx::<T>))
.route("/mempool/add/cert", routing::post(add_cert))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure add_tx and add_cert should be under mempool. I think we can consider mempool just for txs, add_cert should be under da. @zeegomo wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

The concept of a mempool is the same for both, I don't have strong opinions on this but there might be suggestions on the OpenAPI standard on how to handle it

Comment on lines 43 to 84
pub(crate) async fn add_tx<N, A, T>(
handle: &overwatch_rs::overwatch::handle::OverwatchHandle,
tx: T,
) -> Result<(), super::DynError>
where
N: NetworkBackend,
A: NetworkAdapter<Backend = N, Item = T, Key = <T as Transaction>::Hash>
+ Send
+ Sync
+ 'static,
A::Settings: Send + Sync,
T: Transaction
+ Clone
+ Debug
+ Hash
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Send
+ Sync
+ 'static,
<T as Transaction>::Hash: std::cmp::Ord + Debug + Send + Sync + 'static,
{
let relay = handle
.relay::<MempoolService<A, MockPool<T, <T as Transaction>::Hash>, TxDiscriminant>>()
.connect()
.await?;
let (sender, receiver) = oneshot::channel();

relay
.send(MempoolMsg::Add {
key: Transaction::hash(&tx),
item: tx,
reply_channel: sender,
})
.await
.map_err(|(e, _)| e)?;

match receiver.await {
Ok(Ok(())) => Ok(()),
Ok(Err(())) => Err("mempool error".into()),
Err(e) => Err(e.into()),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need two different functions for this, they're the same service with different generics

Comment on lines +100 to +101
.route("/mempool/add/tx", routing::post(add_tx::<T>))
.route("/mempool/add/cert", routing::post(add_cert))
Copy link
Contributor

Choose a reason for hiding this comment

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

The concept of a mempool is the same for both, I don't have strong opinions on this but there might be suggestions on the OpenAPI standard on how to handle it

@@ -30,6 +31,8 @@ pub struct AxumBackendSettings {
pub carnot: OverwatchHandle,
pub network: OverwatchHandle,
pub storage: OverwatchHandle,
pub cert_mempool: OverwatchHandle,
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to keep adding handles?

@al8n al8n requested a review from zeegomo October 30, 2023 15:28
Base automatically changed from storage-api-new to info-api November 1, 2023 07:25
@al8n al8n merged commit 6e1abae into info-api Nov 1, 2023
5 of 6 checks passed
@al8n al8n deleted the mempool-add-apis branch November 1, 2023 07:28
al8n added a commit that referenced this pull request Nov 1, 2023
* Info api

* Da blob api (#487)

* Add storage api for new http backend (#488)

* Mempool add APIs (#489)
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

Successfully merging this pull request may close these issues.

None yet

3 participants