Skip to content

Commit

Permalink
refactor: make taggingMesh flag required
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Jan 29, 2024
1 parent ca7d3d3 commit 3070a88
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export interface GossipsubOpts extends GossipsubOptsSpec, PubSubInit {
/**
* If true, will utilize the libp2p connection manager tagging system to prune/graft connections to peers, defaults to false
*/
tagMeshPeers?: boolean
tagMeshPeers: boolean
}

export interface GossipsubMessage {
Expand Down Expand Up @@ -402,6 +402,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
fallbackToFloodsub: true,
floodPublish: true,
batchPublish: false,
tagMeshPeers: false,
doPX: false,
directPeers: [],
D: constants.GossipsubD,
Expand Down Expand Up @@ -1479,7 +1480,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
const now = Date.now()
let doPX = this.opts.doPX

if (this.opts?.tagMeshPeers ?? false) {
if (this.opts.tagMeshPeers) {
for (const { topicID } of graft) {
if (topicID == null) {
continue
Expand Down Expand Up @@ -1627,7 +1628,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
}
await this.pxConnect(peers)

if (this.opts?.tagMeshPeers ?? false) {
if (this.opts.tagMeshPeers ?? false) {
try {
await this.components.peerStore.merge(peerIdFromString(id), {
tags: {
Expand Down Expand Up @@ -1887,7 +1888,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
// - peer_added_to_mesh()
})

if (this.opts?.tagMeshPeers ?? false) {
if (this.opts.tagMeshPeers ?? false) {
Array.from(toAdd).map(async (id) => {
try {
await this.components.peerStore.merge(peerIdFromString(id), {
Expand Down

0 comments on commit 3070a88

Please sign in to comment.