Skip to content

Commit

Permalink
nit fixes
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Oct 31, 2024
1 parent 4343c0e commit 3b69689
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 3 additions & 1 deletion mm2src/mm2_main/src/lp_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ fn process_p2p_request(
response_channel: mm2_libp2p::AdexResponseChannel,
) -> P2PRequestResult<()> {
let request = decode_message::<P2PRequest>(&request)?;
log::debug!("Got P2PRequest {:?}", request);

let result = match request {
P2PRequest::Ordermatch(req) => lp_ordermatch::process_peer_request(ctx.clone(), req),
P2PRequest::NetworkInfo(req) => lp_stats::process_info_request(ctx.clone(), req),
P2PRequest::NetworkInfo(req) => lp_stats::process_info_request(ctx.clone(), req).map(Some),
};

let res = match result {
Expand Down
1 change: 0 additions & 1 deletion mm2src/mm2_main/src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ impl TryFromBytes for Uuid {
}

pub fn process_peer_request(ctx: MmArc, request: OrdermatchRequest) -> Result<Option<Vec<u8>>, String> {
log::debug!("Got ordermatch request {:?}", request);
match request {
OrdermatchRequest::GetOrderbook { base, rel } => process_get_orderbook_request(ctx, base, rel),
OrdermatchRequest::SyncPubkeyOrderbookState { pubkey, trie_roots } => {
Expand Down
15 changes: 6 additions & 9 deletions mm2src/mm2_main/src/lp_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,20 @@ struct Mm2VersionRes {
nodes: HashMap<String, String>,
}

fn process_get_version_request(ctx: MmArc) -> Result<Option<Vec<u8>>, String> {
fn process_get_version_request(ctx: MmArc) -> Result<Vec<u8>, String> {
let response = ctx.mm_version().to_string();
let encoded = try_s!(encode_message(&response));
Ok(Some(encoded))
encode_message(&response).map_err(|e| e.to_string())
}

fn process_get_peer_utc_timestamp_request(_ctx: MmArc) -> Result<Option<Vec<u8>>, String> {
fn process_get_peer_utc_timestamp_request() -> Result<Vec<u8>, String> {
let timestamp = common::get_utc_timestamp();
let encoded = try_s!(encode_message(&timestamp));
Ok(Some(encoded))
encode_message(&timestamp).map_err(|e| e.to_string())
}

pub fn process_info_request(ctx: MmArc, request: NetworkInfoRequest) -> Result<Option<Vec<u8>>, String> {
log::debug!("Got stats request {:?}", request);
pub fn process_info_request(ctx: MmArc, request: NetworkInfoRequest) -> Result<Vec<u8>, String> {
match request {
NetworkInfoRequest::GetMm2Version => process_get_version_request(ctx),
NetworkInfoRequest::GetPeerUtcTimestamp => process_get_peer_utc_timestamp_request(ctx),
NetworkInfoRequest::GetPeerUtcTimestamp => process_get_peer_utc_timestamp_request(),
}
}

Expand Down

0 comments on commit 3b69689

Please sign in to comment.