Skip to content

Commit

Permalink
Update ProtocolResponse (#1369)
Browse files Browse the repository at this point in the history
* Update `ProtocolResponse`

* Fix protocolVersion type

* Return IOTA_SUPPLY as String in ProtocolResponse
  • Loading branch information
samuel-rufi authored Apr 27, 2022
1 parent 34057ff commit d629d6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bee-api/bee-rest-api/src/endpoints/routes/api/v2/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use std::{convert::Infallible, net::IpAddr};

use bee_message::constant::{IOTA_SUPPLY, PROTOCOL_VERSION};
use bee_protocol::workers::{config::ProtocolConfig, PeerManager};
use bee_runtime::{node::NodeInfo, resource::ResourceHandle};
use bee_tangle::Tangle;
Expand Down Expand Up @@ -91,6 +92,7 @@ pub(crate) fn info<B: StorageBackend>(
pruning_index: *tangle.get_pruning_index(),
},
protocol: ProtocolResponse {
version: PROTOCOL_VERSION,
network_name: network_id.0,
bech32_hrp,
min_pow_score: protocol_config.minimum_pow_score(),
Expand All @@ -99,6 +101,7 @@ pub(crate) fn info<B: StorageBackend>(
v_byte_factor_key: protocol_config.byte_cost().v_byte_factor_key,
v_byte_factor_data: protocol_config.byte_cost().v_byte_factor_data,
},
token_supply: IOTA_SUPPLY.to_string(),
},
metrics: MetricsResponse {
messages_per_second: 0.0, // TODO
Expand Down
4 changes: 4 additions & 0 deletions bee-api/bee-rest-api/src/types/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct StatusResponse {
/// Protocol information about the node.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ProtocolResponse {
#[serde(rename = "protocolVersion")]
pub version: u8,
#[serde(rename = "networkName")]
pub network_name: String,
#[serde(rename = "bech32HRP")]
Expand All @@ -52,6 +54,8 @@ pub struct ProtocolResponse {
pub min_pow_score: f64,
#[serde(rename = "rentStructure")]
pub rent_structure: RentStructureResponse,
#[serde(rename = "tokenSupply")]
pub token_supply: String,
}

/// Returned in [`InfoResponse`].
Expand Down

0 comments on commit d629d6e

Please sign in to comment.