API reference › @evolu/common › local‑first/Protocol › createProtocolMessageFromCrdtMessages

function createProtocolMessageFromCrdtMessages(
  deps: RandomBytesDep,
): (
  owner: Owner,
  messages: readonly [CrdtMessage, CrdtMessage],
  maxSize?: number &
    Brand<"NonNaN"> &
    Brand<"Finite"> &
    Brand<"Int"> &
    Brand<"Between1000000-100000000">,
) => ProtocolMessage;

Defined in: packages/common/src/local-first/Protocol.ts:595

Creates a ProtocolMessage from CRDT messages.

The message holds the leading CRDT messages that fit maxSize, by default defaultProtocolMessageMaxSize, measured exactly. When one does not fit, it and the rest are left out, and the message ends with a range that makes the non-initiator answer with ranges. Sync then sends them in later rounds, even over unidirectional and stateless transports, because every change within maxMutationSize fits an empty message.