Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

deps: bump protons-runtime from 4.0.2 to 5.0.0 #416

Merged
merged 5 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"p-defer": "^4.0.0",
"p-queue": "^7.2.0",
"private-ip": "^3.0.0",
"protons-runtime": "^4.0.1",
"protons-runtime": "^5.0.0",
"timeout-abort-controller": "^3.0.0",
"uint8arraylist": "^2.0.0",
"uint8arrays": "^4.0.2",
Expand All @@ -205,7 +205,7 @@
"lodash.range": "^3.2.0",
"p-retry": "^5.0.0",
"p-wait-for": "^5.0.0",
"protons": "^6.0.0",
"protons": "^7.0.2",
"sinon": "^15.0.0",
"ts-sinon": "^2.0.2",
"which": "^3.0.0"
Expand Down
91 changes: 44 additions & 47 deletions src/message/dht.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* 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 */

import { encodeMessage, decodeMessage, message, enumeration } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

export interface Record {
key?: Uint8Array
Expand All @@ -18,38 +21,38 @@ export namespace Record {

export const codec = (): Codec<Record> => {
if (_codec == null) {
_codec = message<Record>((obj, writer, opts = {}) => {
_codec = message<Record>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.key != null) {
writer.uint32(10)
writer.bytes(obj.key)
w.uint32(10)
w.bytes(obj.key)
}

if (obj.value != null) {
writer.uint32(18)
writer.bytes(obj.value)
w.uint32(18)
w.bytes(obj.value)
}

if (obj.author != null) {
writer.uint32(26)
writer.bytes(obj.author)
w.uint32(26)
w.bytes(obj.author)
}

if (obj.signature != null) {
writer.uint32(34)
writer.bytes(obj.signature)
w.uint32(34)
w.bytes(obj.signature)
}

if (obj.timeReceived != null) {
writer.uint32(42)
writer.string(obj.timeReceived)
w.uint32(42)
w.string(obj.timeReceived)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
Expand Down Expand Up @@ -88,7 +91,7 @@ export namespace Record {
return _codec
}

export const encode = (obj: Record): Uint8Array => {
export const encode = (obj: Partial<Record>): Uint8Array => {
return encodeMessage(obj, Record.codec())
}

Expand Down Expand Up @@ -162,32 +165,30 @@ export namespace Message {

export const codec = (): Codec<Peer> => {
if (_codec == null) {
_codec = message<Peer>((obj, writer, opts = {}) => {
_codec = message<Peer>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.id != null) {
writer.uint32(10)
writer.bytes(obj.id)
w.uint32(10)
w.bytes(obj.id)
}

if (obj.addrs != null) {
for (const value of obj.addrs) {
writer.uint32(18)
writer.bytes(value)
w.uint32(18)
w.bytes(value)
}
} else {
throw new Error('Protocol error: required field "addrs" was not found in object')
}

if (obj.connection != null) {
writer.uint32(24)
Message.ConnectionType.codec().encode(obj.connection, writer)
w.uint32(24)
Message.ConnectionType.codec().encode(obj.connection, w)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {
Expand Down Expand Up @@ -222,7 +223,7 @@ export namespace Message {
return _codec
}

export const encode = (obj: Peer): Uint8Array => {
export const encode = (obj: Partial<Peer>): Uint8Array => {
return encodeMessage(obj, Peer.codec())
}

Expand All @@ -235,51 +236,47 @@ export namespace Message {

export const codec = (): Codec<Message> => {
if (_codec == null) {
_codec = message<Message>((obj, writer, opts = {}) => {
_codec = message<Message>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.type != null) {
writer.uint32(8)
Message.MessageType.codec().encode(obj.type, writer)
w.uint32(8)
Message.MessageType.codec().encode(obj.type, w)
}

if (obj.clusterLevelRaw != null) {
writer.uint32(80)
writer.int32(obj.clusterLevelRaw)
w.uint32(80)
w.int32(obj.clusterLevelRaw)
}

if (obj.key != null) {
writer.uint32(18)
writer.bytes(obj.key)
w.uint32(18)
w.bytes(obj.key)
}

if (obj.record != null) {
writer.uint32(26)
writer.bytes(obj.record)
w.uint32(26)
w.bytes(obj.record)
}

if (obj.closerPeers != null) {
for (const value of obj.closerPeers) {
writer.uint32(66)
Message.Peer.codec().encode(value, writer)
w.uint32(66)
Message.Peer.codec().encode(value, w)
}
} else {
throw new Error('Protocol error: required field "closerPeers" was not found in object')
}

if (obj.providerPeers != null) {
for (const value of obj.providerPeers) {
writer.uint32(74)
Message.Peer.codec().encode(value, writer)
w.uint32(74)
Message.Peer.codec().encode(value, w)
}
} else {
throw new Error('Protocol error: required field "providerPeers" was not found in object')
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {
Expand Down Expand Up @@ -324,7 +321,7 @@ export namespace Message {
return _codec
}

export const encode = (obj: Message): Uint8Array => {
export const encode = (obj: Partial<Message>): Uint8Array => {
return encodeMessage(obj, Message.codec())
}

Expand Down