File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ const EventHandlerError = require('./event-handler-error');
13
13
const { EventHandlerErrorCode } = require ( '../common/result-code' ) ;
14
14
const BlockchainEvent = require ( './blockchain-event' ) ;
15
15
16
+ const CHANNEL_ID_RANDOM_NUMBER_RANGE = 1000 ;
17
+
16
18
class EventChannelManager {
17
19
constructor ( node ) {
18
20
this . node = node ;
@@ -107,7 +109,9 @@ class EventChannelManager {
107
109
`The number of event channels exceeds its limit ` +
108
110
`(${ NodeConfigs . MAX_NUM_EVENT_CHANNELS } )` ) ;
109
111
}
110
- const channelId = Date . now ( ) ; // NOTE: Only used in blockchain
112
+ // NOTE: Only used in blockchain
113
+ const channelId
114
+ = String ( Date . now ( ) + Math . floor ( Math . random ( ) * CHANNEL_ID_RANDOM_NUMBER_RANGE ) ) ;
111
115
if ( this . channels [ channelId ] ) { // TODO(cshcomcom): Retry logic.
112
116
webSocket . terminate ( ) ;
113
117
throw new EventHandlerError ( EventHandlerErrorCode . DUPLICATED_CHANNEL_ID ,
You can’t perform that action at this time.
0 commit comments