discv5_cli/packet/
mod.rs

1//! Handles the packet-based logic functions
2
3/// The [clap] cli command arguments for the packet service.
4pub mod command;
5pub use command::*;
6
7/// Decodes a packet based on the CLI options.
8pub fn decode(decode: &Decode) {
9    let packet_bytes = hex::decode(&decode.packet).expect("Packet bytes must be valid hex");
10
11    let node_id = discv5::enr::NodeId::parse(
12        &hex::decode(&decode.node_id).expect("Node Id must be valid hex bytes"),
13    )
14    .expect("Must be a valid node-id");
15
16    log::info!("Using decoding node id: {}", node_id);
17
18    match discv5::packet::Packet::decode::<discv5::DefaultProtocolId>(&node_id, &packet_bytes) {
19        Ok(p) => log::info!("Packet decoded: {:?}", p),
20        Err(e) => log::error!("Packet failed to be decoded. Error: {:?}", e),
21    }
22}