@@ -85,6 +85,10 @@ type ReceivedMessageResult =
85
85
| ( { code : MessageStatus . invalid ; msgIdStr ?: MsgIdStr } & RejectReasonObj )
86
86
| { code : MessageStatus . valid ; messageId : MessageId ; msg : Message }
87
87
88
+ export type PublishOpts = {
89
+ skipDuplicateCheck : boolean
90
+ }
91
+
88
92
export const multicodec : string = constants . GossipsubIDv11
89
93
90
94
export interface GossipsubOpts extends GossipsubOptsSpec , PubSubInit {
@@ -1922,7 +1926,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
1922
1926
*
1923
1927
* For messages not from us, this class uses `forwardMessage`.
1924
1928
*/
1925
- async publish ( topic : TopicStr , data : Uint8Array ) : Promise < PublishResult > {
1929
+ async publish ( topic : TopicStr , data : Uint8Array , opts ?: PublishOpts ) : Promise < PublishResult > {
1926
1930
const transformedData = this . dataTransform ? this . dataTransform . outboundTransform ( topic , data ) : data
1927
1931
1928
1932
if ( this . publishConfig == null ) {
@@ -1936,7 +1940,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
1936
1940
const msgId = await this . msgIdFn ( msg )
1937
1941
const msgIdStr = this . msgIdToStrFn ( msgId )
1938
1942
1939
- if ( this . seenCache . has ( msgIdStr ) ) {
1943
+ if ( ! opts ?. skipDuplicateCheck && this . seenCache . has ( msgIdStr ) ) {
1940
1944
// This message has already been seen. We don't re-publish messages that have already
1941
1945
// been published on the network.
1942
1946
throw Error ( 'PublishError.Duplicate' )
0 commit comments