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

Add Transactions topic #37

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdn-proto/schema/messages_capnp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ pub mod message {
pub enum Topic {
Global = 0,
Da = 1,
Transactions = 2,
}

impl ::capnp::introspect::Introspect for Topic {
Comment on lines 586 to 592
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think instead we want to update messages.capnp and then run something like capnp compile -o rust cdn-proto/schema/*.capnp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, didn't notice the DO NOT EDIT comment at the top. Thanks!

Expand All @@ -600,6 +601,7 @@ impl ::core::convert::TryFrom<u16> for Topic {
match value {
0 => ::core::result::Result::Ok(Self::Global),
1 => ::core::result::Result::Ok(Self::Da),
2 => ::core::result::Result::Ok(Self::Transactions),
n => ::core::result::Result::Err(::capnp::NotInSchema(n)),
}
}
Expand Down
7 changes: 6 additions & 1 deletion cdn-proto/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ pub enum Topic {
/// The DA-specfic topic. Only participants in the DA committee should want to
/// be subscribed to this.
DA,
/// The topic with transactions. Only soon-to-be-leaders should want to be subscribed to this.
Transactions,
}

/// We need this because it allows conversions to and from the Cap'n' Proto version
Expand All @@ -329,6 +331,7 @@ impl From<messages_capnp::Topic> for Topic {
match value {
messages_capnp::Topic::Global => Self::Global,
messages_capnp::Topic::Da => Self::DA,
messages_capnp::Topic::Transactions => Self::Transactions,
}
}
}
Expand All @@ -340,6 +343,7 @@ impl From<Topic> for messages_capnp::Topic {
match value {
Topic::Global => Self::Global,
Topic::DA => Self::Da,
Topic::Transactions => Self::Transactions,
}
}
}
Expand All @@ -352,7 +356,7 @@ impl TryInto<Topic> for String {
match self.as_str() {
"DA" => Ok(Topic::DA),
"Global" => Ok(Topic::Global),

"Transactions" => Ok(Topic::Transactions),
_ => Err(Error::Parse(
"failed to parse topic: did not exist".to_string(),
)),
Expand All @@ -366,6 +370,7 @@ impl Display for Topic {
match self {
Self::Global => write!(f, "Global"),
Self::DA => write!(f, "DA"),
Self::Transactions => write!(f, "Transactions"),
}
}
}
Expand Down