diff --git a/src/json-crdt/codec/structural/binary/Decoder.ts b/src/json-crdt/codec/structural/binary/Decoder.ts index 15c213bb42..11b27b33ff 100644 --- a/src/json-crdt/codec/structural/binary/Decoder.ts +++ b/src/json-crdt/codec/structural/binary/Decoder.ts @@ -78,22 +78,21 @@ export class Decoder extends CborDecoderBase { const octet = reader.u8(); const major = octet >> 5; const minor = octet & 0b11111; - const length = minor < 0b11111 ? minor : reader.vu57(); switch (major) { case CRDT_MAJOR.CON: - return this.cCon(id, length); + return this.cCon(id, minor); case CRDT_MAJOR.VAL: return this.cVal(id); case CRDT_MAJOR.OBJ: - return this.cObj(id, length); + return this.cObj(id, minor < 0b11111 ? minor : reader.vu57()); case CRDT_MAJOR.VEC: - return this.cVec(id, length); + return this.cVec(id, minor < 0b11111 ? minor : reader.vu57()); case CRDT_MAJOR.STR: - return this.cStr(id, length); + return this.cStr(id, minor < 0b11111 ? minor : reader.vu57()); case CRDT_MAJOR.BIN: - return this.cBin(id, length); + return this.cBin(id, minor < 0b11111 ? minor : reader.vu57()); case CRDT_MAJOR.ARR: - return this.cArr(id, length); + return this.cArr(id, minor < 0b11111 ? minor : reader.vu57()); } throw new Error('UNKNOWN_NODE'); } diff --git a/src/json-crdt/codec/structural/binary/Encoder.ts b/src/json-crdt/codec/structural/binary/Encoder.ts index 13aaf3209d..8e28e23865 100644 --- a/src/json-crdt/codec/structural/binary/Encoder.ts +++ b/src/json-crdt/codec/structural/binary/Encoder.ts @@ -104,20 +104,17 @@ export class Encoder extends CborEncoder { const val = node.val; this.ts(node.id); if (val instanceof Timestamp) { - // this.writeTL(CRDT_MAJOR_OVERLAY.CON, 1); - this.writer.u8(1); + this.writer.u8(1); // this.writeTL(CRDT_MAJOR_OVERLAY.CON, 1); this.ts(val as Timestamp); } else { - // this.writeTL(CRDT_MAJOR_OVERLAY.CON, 0); - this.writer.u8(0); + this.writer.u8(0); // this.writeTL(CRDT_MAJOR_OVERLAY.CON, 0); this.writeAny(val); } } protected cVal(node: nodes.ValNode): void { this.ts(node.id); - // this.writeTL(CRDT_MAJOR_OVERLAY.VAL, 0); - this.writer.u8(0b00100000); + this.writer.u8(0b00100000); // this.writeTL(CRDT_MAJOR_OVERLAY.VAL, 0); this.cNode(node.node()); } diff --git a/src/json-crdt/codec/structural/binary/README.md b/src/json-crdt/codec/structural/binary/README.md deleted file mode 100644 index db876dee46..0000000000 --- a/src/json-crdt/codec/structural/binary/README.md +++ /dev/null @@ -1,9 +0,0 @@ -| JSON CRDT node type | CBOR encoding | -| ------------------- | ------------- | -| `con` | Major type 0 | -| `val` | Major type 1 | -| `vec` | Major type 2 | -| `obj` | Major type 3 | -| `str` | Major type 4 | -| `bin` | Major type 5 | -| `arr` | Major type 6 |