Skip to content

Commit

Permalink
chore: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain authored Feb 20, 2023
1 parent 2d30405 commit 68c897b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface GossipsubOpts extends GossipsubOptsSpec, PubSubInit {
/** Do not throw `InsufficientPeers` error if publishing to zero peers */
allowPublishToZeroPeers: boolean
/** Do not throw `PublishError.Duplicate` if publishing duplicate messages */
ignoreDuplicateMessages: boolean
allowPublishDuplicateMessages: boolean
/** For a single stream, await processing each RPC before processing the next */
awaitRpcHandler: boolean
/** For a single RPC, await processing each message before processing the next */
Expand Down Expand Up @@ -2016,13 +2016,13 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
const msgIdStr = this.msgIdToStrFn(msgId)

// Current publish opt takes precedence global opts, while preserving false value
const ignoreDuplicateMessages = opts?.ignoreDuplicateMessages ?? this.opts.ignoreDuplicateMessages
const allowPublishDuplicateMessages = opts?.allowPublishDuplicateMessages ?? this.opts.allowPublishDuplicateMessages

if (this.seenCache.has(msgIdStr)) {
// This message has already been seen. We don't re-publish messages that have already
// been published on the network.
if (ignoreDuplicateMessages) {
this.metrics?.onIgnorePublishedDuplicateMsg(topic)
if (allowPublishDuplicateMessages) {
this.metrics?.onPublishDuplicateMsg(topic)
return { recipients: [] }
}
throw Error('PublishError.Duplicate')
Expand Down
2 changes: 1 addition & 1 deletion src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ export function getMetrics(
}
},

onIgnorePublishedDuplicateMsg(topicStr: TopicStr): void {
onPublishDuplicateMsg(topicStr: TopicStr): void {
const topic = this.toTopic(topicStr)
this.duplicateMsgIgnored.inc({ topic }, 1)
},
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export enum SignaturePolicy {

export type PublishOpts = {
allowPublishToZeroPeers?: boolean
ignoreDuplicateMessages?: boolean
allowPublishDuplicateMessages?: boolean
}

export enum PublishConfigType {
Expand Down

0 comments on commit 68c897b

Please sign in to comment.