Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 11, 2024
1 parent a4e25ad commit 1d0479e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub

// remove explicit peers, peers with negative scores, and backoffed peers
fanoutPeers.forEach((id) => {
if (!this.direct.has(id) && this.score.score(id) >= 0 && ((backoff == null) || !backoff.has(id))) {
if (!this.direct.has(id) && this.score.score(id) >= 0 && backoff?.has(id) !== true) {
toAdd.add(id)
}
})
Expand All @@ -1914,7 +1914,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
this.opts.D,
(id: PeerIdStr): boolean =>
// filter direct peers and peers with negative score
!toAdd.has(id) && !this.direct.has(id) && this.score.score(id) >= 0 && ((backoff == null) || !backoff.has(id))
!toAdd.has(id) && !this.direct.has(id) && this.score.score(id) >= 0 && backoff?.has(id) !== true
)

newPeers.forEach((peer) => {
Expand Down Expand Up @@ -2744,7 +2744,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
!this.direct.has(id)
) {
const score = getScore(id)
if (((backoff == null) || !backoff.has(id)) && score >= 0) candidateMeshPeers.add(id)
if (backoff?.has(id) !== true && score >= 0) candidateMeshPeers.add(id)
// instead of having to find gossip peers after heartbeat which require another loop
// we prepare peers to gossip in a topic within heartbeat to improve performance
if (score >= this.opts.scoreThresholds.gossipThreshold) peersToGossip.add(id)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/buildRawMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function buildRawMessage (
type: 'signed',
from: publishConfig.author,
data: originalData,
sequenceNumber: BigInt(`0x${uint8ArrayToString(rpcMsg.seqno as Uint8Array, 'base16')}`),
sequenceNumber: BigInt(`0x${uint8ArrayToString(rpcMsg.seqno ?? new Uint8Array(0), 'base16')}`),
topic,
signature: rpcMsg.signature,
key: publicKeyFromProtobuf(rpcMsg.key)
Expand Down
2 changes: 1 addition & 1 deletion test/utils/msgId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { messageIdToString } from '../../src/utils/messageIdToString.js'
import type { RPC } from '../../src/message/rpc.js'

export const getMsgId = (msg: RPC.Message): Uint8Array => {
const from = msg.from != null ? msg.from : new Uint8Array(0)
const from = msg.from ?? new Uint8Array(0)
const seqno = msg.seqno instanceof Uint8Array ? msg.seqno : uint8ArrayFromString(msg.seqno ?? '')
const result = new Uint8Array(from.length + seqno.length)
result.set(from, 0)
Expand Down

0 comments on commit 1d0479e

Please sign in to comment.