forest/libp2p/hello/codec.rs
1// Copyright 2019-2026 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use std::time::Duration;
5
6use super::*;
7use crate::libp2p::rpc::{CborRequestResponse, CodecConfig};
8
9/// Codec limits for the Hello protocol.
10///
11/// - Request: tipset CIDs + height + weight + genesis CID — comfortably under
12/// 1 KiB even at the 15-blocks-per-tipset ceiling. 4 KiB cap.
13/// - Response: `[u64, u64]`, at most **19 bytes** CBOR-encoded. 32 byte cap.
14/// - Decode timeout: 10 seconds — the response is tiny, anything stalling longer is
15/// misbehaving.
16pub struct HelloCodecConfig;
17
18impl CodecConfig for HelloCodecConfig {
19 const MAX_REQUEST_BYTES: usize = 4096;
20 const MAX_RESPONSE_BYTES: usize = 32;
21 const DECODE_TIMEOUT: Duration = Duration::from_secs(10);
22}
23
24pub type HelloCodec =
25 CborRequestResponse<&'static str, HelloRequest, HelloResponse, HelloCodecConfig>;