MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / chunk_wire_envelopes

Function chunk_wire_envelopes

atomic-cli/src/commands/agent/provenance_rpc.rs:495–512  ·  view source on GitHub ↗
(envelopes: Vec<pb::WireEnvelope>)

Source from the content-addressed store, hash-verified

493}
494
495pub(crate) fn chunk_wire_envelopes(envelopes: Vec<pb::WireEnvelope>) -> Vec<Vec<pb::WireEnvelope>> {
496 let mut chunks: Vec<Vec<pb::WireEnvelope>> = Vec::new();
497 let mut current: Vec<pb::WireEnvelope> = Vec::new();
498 let mut current_cost = 0usize;
499 for envelope in envelopes {
500 let cost = wire_envelope_frame_cost(&envelope);
501 if !current.is_empty() && current_cost + cost > APPEND_CHUNK_BUDGET_BYTES {
502 chunks.push(std::mem::take(&mut current));
503 current_cost = 0;
504 }
505 current_cost += cost;
506 current.push(envelope);
507 }
508 if !current.is_empty() {
509 chunks.push(current);
510 }
511 chunks
512}
513
514// ---------------------------------------------------------------------------
515// frozen page reassembly (ported verbatim from the legacy owner client)

Calls 3

wire_envelope_frame_costFunction · 0.85
is_emptyMethod · 0.45
pushMethod · 0.45