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

Fix milestone timestamp in API #1322

Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 7 additions & 12 deletions bee-api/bee-rest-api/src/endpoints/routes/api/v1/milestone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,14 @@ pub(crate) fn milestone<B: StorageBackend>(
milestone_index: MilestoneIndex,
tangle: ResourceHandle<Tangle<B>>,
) -> Result<impl Reply, Rejection> {
match tangle.get_milestone_message_id(milestone_index) {
Some(message_id) => match tangle.get_metadata(&message_id) {
Some(metadata) => Ok(warp::reply::json(&SuccessBody::new(MilestoneResponse {
milestone_index: *milestone_index,
message_id: message_id.to_string(),
timestamp: metadata.arrival_timestamp(),
}))),
None => Err(reject::custom(CustomRejection::NotFound(
"can not find metadata for milestone".to_string(),
))),
},
match tangle.get_milestone(milestone_index) {
Some(milestone) => Ok(warp::reply::json(&SuccessBody::new(MilestoneResponse {
milestone_index: *milestone_index,
message_id: milestone.message_id().to_string(),
timestamp: milestone.timestamp(),
}))),
None => Err(reject::custom(CustomRejection::NotFound(
"can not find milestone".to_string(),
"cannot find milestone".to_string(),
))),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ impl ProtocolsHandler for GossipProtocolHandler {
/// substreams to negotiate the desired protocols.
///
/// > **Note**: The returned `InboundUpgrade` should always accept all the generally
/// > supported protocols, even if in a specific context a particular one is
/// > not supported, (eg. when only allowing one substream at a time for a protocol).
/// > This allows a remote to put the list of supported protocols in a cache.
/// > supported protocols, even if in a specific context a particular one is
/// > not supported, (eg. when only allowing one substream at a time for a protocol).
/// > This allows a remote to put the list of supported protocols in a cache.
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
debug!("gossip handler: responding to listen protocol request.");

Expand Down