MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / close_on_version_error

Function close_on_version_error

nodedb-cluster/src/wire_version/handshake_io.rs:162–172  ·  view source on GitHub ↗

Map a [`WireVersionError`] to a `ClusterError::Transport` with the QUIC connection closed. Helper shared by callers that have already negotiated but encounter a per-frame version mismatch.

(conn: &quinn::Connection, e: WireVersionError)

Source from the content-addressed store, hash-verified

160/// connection closed. Helper shared by callers that have already negotiated
161/// but encounter a per-frame version mismatch.
162pub fn close_on_version_error(conn: &quinn::Connection, e: WireVersionError) -> ClusterError {
163 let reason = e.to_string();
164 let reason_bytes = reason.as_bytes();
165 conn.close(
166 quinn::VarInt::from_u32(0x01),
167 &reason_bytes[..reason_bytes.len().min(100)],
168 );
169 ClusterError::Transport {
170 detail: format!("wire version mismatch: {e}"),
171 }
172}
173
174#[cfg(test)]
175mod tests {

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
closeMethod · 0.80
as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected