@@ -85,6 +85,10 @@ type ReceivedMessageResult =
8585 | ( { code : MessageStatus . invalid ; msgIdStr ?: MsgIdStr } & RejectReasonObj )
8686 | { code : MessageStatus . valid ; messageId : MessageId ; msg : Message }
8787
88+ export type PublishOpts = {
89+ skipDuplicateCheck : boolean
90+ }
91+
8892export const multicodec : string = constants . GossipsubIDv11
8993
9094export interface GossipsubOpts extends GossipsubOptsSpec , PubSubInit {
@@ -1922,7 +1926,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
19221926 *
19231927 * For messages not from us, this class uses `forwardMessage`.
19241928 */
1925- async publish ( topic : TopicStr , data : Uint8Array ) : Promise < PublishResult > {
1929+ async publish ( topic : TopicStr , data : Uint8Array , opts ?: PublishOpts ) : Promise < PublishResult > {
19261930 const transformedData = this . dataTransform ? this . dataTransform . outboundTransform ( topic , data ) : data
19271931
19281932 if ( this . publishConfig == null ) {
@@ -1936,7 +1940,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
19361940 const msgId = await this . msgIdFn ( msg )
19371941 const msgIdStr = this . msgIdToStrFn ( msgId )
19381942
1939- if ( this . seenCache . has ( msgIdStr ) ) {
1943+ if ( ! opts ?. skipDuplicateCheck && this . seenCache . has ( msgIdStr ) ) {
19401944 // This message has already been seen. We don't re-publish messages that have already
19411945 // been published on the network.
19421946 throw Error ( 'PublishError.Duplicate' )
0 commit comments