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

Review comments #84

Merged
merged 5 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/muxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ export class DataChannelMuxer implements StreamMuxer {
/**
* Initiate a new stream with the given name. If no name is
* provided, the id of the stream will be used.
* TODO does this comment make sense? The spec says the label SHOULD be an empty string
*/
newStream (name: string = ''): Stream {
// TODO The spec says the label SHOULD be an empty string: https://github.com/libp2p/specs/blob/master/webrtc/README.md#rtcdatachannel-label
MarcoPolo marked this conversation as resolved.
Show resolved Hide resolved
const channel = this.peerConnection.createDataChannel(name)
const stream = new WebRTCStream({
channel,
Expand Down
9 changes: 2 additions & 7 deletions src/sdp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ const log = logger('libp2p:webrtc:sdp')
/**
* Get base2 | identity decoders
*/
export const mbdecoder: any = (function () {
const decoders = Object.values(bases).map((b) => b.decoder)
let acc = decoders[0].or(decoders[1])
decoders.slice(2).forEach((d) => (acc = acc.or(d)))
return acc
})()
// @ts-expect-error - Not easy to combine these types.
export const mbdecoder: any = Object.values(bases).map(b => b.decoder).reduce((d, b) => d.or(b))

/**
* Get base2 | identity decoders
Expand Down Expand Up @@ -57,7 +53,6 @@ export function decodeCerthash (certhash: string) {
* Extract the fingerprint from a multiaddr
*/
export function ma2Fingerprint (ma: Multiaddr): string[] {
// certhash_value is a multibase encoded multihash encoded string
const mhdecoded = decodeCerthash(certhash(ma))
const prefix = toSupportedHashFunction(mhdecoded.name)
const fingerprint = mhdecoded.digest.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
Expand Down
Loading