1
1
import { EventEmitter , CustomEvent } from '@libp2p/interfaces/events' ;
2
2
import { Client } from '../index.js' ;
3
- import { GenericOfferOptions , GenericQuery , RequestData , OfferData } from '../shared/messages .js' ;
3
+ import { GenericOfferOptions , GenericQuery , RequestData , OfferData } from '../shared/types .js' ;
4
4
import { Storage } from '../storage/index.js' ;
5
5
import { createLogger } from '../utils/logger.js' ;
6
6
import { encodeText } from '../utils/text.js' ;
7
7
import { nowSec } from '../utils/time.js' ;
8
+ import { stringify } from '../utils/hash.js' ;
8
9
9
10
const logger = createLogger ( 'RequestsRegistry' ) ;
10
11
@@ -272,9 +273,9 @@ export class RequestsRegistry<
272
273
throw new Error ( 'Client not connected to the coordination server yet' ) ;
273
274
}
274
275
275
- const now = nowSec ( ) ;
276
+ const now = BigInt ( nowSec ( ) ) ;
276
277
277
- if ( record . data . expire < nowSec ( ) || record . cancelled ) {
278
+ if ( BigInt ( record . data . expire ) < nowSec ( ) || record . cancelled ) {
278
279
return ;
279
280
}
280
281
@@ -288,7 +289,7 @@ export class RequestsRegistry<
288
289
} ) ,
289
290
) ;
290
291
this . _unsubscribe ( record . data . id ) ;
291
- } , ( record . data . expire - now ) * 1000 ) ,
292
+ } , Number ( ( BigInt ( record . data . expire ) - now ) * BigInt ( 1000 ) ) ) ,
292
293
) ;
293
294
this . dispatchEvent (
294
295
new CustomEvent < string > ( 'subscribe' , {
@@ -339,7 +340,7 @@ export class RequestsRegistry<
339
340
this . _subscribe ( requestRecord ) ;
340
341
341
342
this . client . libp2p . pubsub
342
- . publish ( request . topic , encodeText ( JSON . stringify ( request ) ) )
343
+ . publish ( request . topic , encodeText ( stringify ( request ) ) )
343
344
. then ( ( ) => {
344
345
this . dispatchEvent (
345
346
new CustomEvent < string > ( 'published' , {
0 commit comments