@waku/proto
Version:
Protobuf definitions for Waku
167 lines • 6.47 kB
JavaScript
/* eslint-disable import/export */
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable import/consistent-type-specifier-style */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { decodeMessage, encodeMessage, MaxLengthError, message } from 'protons-runtime';
export var HistoryEntry;
(function (HistoryEntry) {
let _codec;
HistoryEntry.codec = () => {
if (_codec == null) {
_codec = message((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
w.fork();
}
if ((obj.messageId != null && obj.messageId !== '')) {
w.uint32(10);
w.string(obj.messageId);
}
if (obj.retrievalHint != null) {
w.uint32(18);
w.bytes(obj.retrievalHint);
}
if (opts.lengthDelimited !== false) {
w.ldelim();
}
}, (reader, length, opts = {}) => {
const obj = {
messageId: ''
};
const end = length == null ? reader.len : reader.pos + length;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
obj.messageId = reader.string();
break;
}
case 2: {
obj.retrievalHint = reader.bytes();
break;
}
default: {
reader.skipType(tag & 7);
break;
}
}
}
return obj;
});
}
return _codec;
};
HistoryEntry.encode = (obj) => {
return encodeMessage(obj, HistoryEntry.codec());
};
HistoryEntry.decode = (buf, opts) => {
return decodeMessage(buf, HistoryEntry.codec(), opts);
};
})(HistoryEntry || (HistoryEntry = {}));
export var SdsMessage;
(function (SdsMessage) {
let _codec;
SdsMessage.codec = () => {
if (_codec == null) {
_codec = message((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
w.fork();
}
if ((obj.senderId != null && obj.senderId !== '')) {
w.uint32(10);
w.string(obj.senderId);
}
if ((obj.messageId != null && obj.messageId !== '')) {
w.uint32(18);
w.string(obj.messageId);
}
if ((obj.channelId != null && obj.channelId !== '')) {
w.uint32(26);
w.string(obj.channelId);
}
if (obj.lamportTimestamp != null) {
w.uint32(80);
w.int32(obj.lamportTimestamp);
}
if (obj.causalHistory != null) {
for (const value of obj.causalHistory) {
w.uint32(90);
HistoryEntry.codec().encode(value, w);
}
}
if (obj.bloomFilter != null) {
w.uint32(98);
w.bytes(obj.bloomFilter);
}
if (obj.content != null) {
w.uint32(162);
w.bytes(obj.content);
}
if (opts.lengthDelimited !== false) {
w.ldelim();
}
}, (reader, length, opts = {}) => {
const obj = {
senderId: '',
messageId: '',
channelId: '',
causalHistory: []
};
const end = length == null ? reader.len : reader.pos + length;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
obj.senderId = reader.string();
break;
}
case 2: {
obj.messageId = reader.string();
break;
}
case 3: {
obj.channelId = reader.string();
break;
}
case 10: {
obj.lamportTimestamp = reader.int32();
break;
}
case 11: {
if (opts.limits?.causalHistory != null && obj.causalHistory.length === opts.limits.causalHistory) {
throw new MaxLengthError('Decode error - map field "causalHistory" had too many elements');
}
obj.causalHistory.push(HistoryEntry.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.causalHistory$
}));
break;
}
case 12: {
obj.bloomFilter = reader.bytes();
break;
}
case 20: {
obj.content = reader.bytes();
break;
}
default: {
reader.skipType(tag & 7);
break;
}
}
}
return obj;
});
}
return _codec;
};
SdsMessage.encode = (obj) => {
return encodeMessage(obj, SdsMessage.codec());
};
SdsMessage.decode = (buf, opts) => {
return decodeMessage(buf, SdsMessage.codec(), opts);
};
})(SdsMessage || (SdsMessage = {}));
//# sourceMappingURL=sds_message.js.map