File tree 3 files changed +15
-8
lines changed
packages/transport-circuit-relay-v2/src/transport
3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,14 @@ export class RelayDiscovery extends TypedEventEmitter<RelayDiscoveryEvents> impl
59
59
}
60
60
} )
61
61
62
+ this . started = true
63
+ }
64
+
65
+ afterStart ( ) : void {
62
66
void this . discover ( )
63
67
. catch ( err => {
64
- this . log . error ( 'error listening on relays' , err )
68
+ this . log . error ( 'error discovering relays' , err )
65
69
} )
66
-
67
- this . started = true
68
70
}
69
71
70
72
stop ( ) : void {
Original file line number Diff line number Diff line change @@ -115,11 +115,11 @@ export class ReservationStore extends TypedEventEmitter<ReservationStoreEvents>
115
115
return this . started
116
116
}
117
117
118
- async start ( ) : Promise < void > {
118
+ start ( ) : void {
119
119
this . started = true
120
120
}
121
121
122
- async stop ( ) : Promise < void > {
122
+ stop ( ) : void {
123
123
this . reserveQueue . clear ( )
124
124
this . reservations . forEach ( ( { timeout } ) => {
125
125
clearTimeout ( timeout )
Original file line number Diff line number Diff line change @@ -103,8 +103,7 @@ export class CircuitRelayTransport implements Transport {
103
103
}
104
104
105
105
async start ( ) : Promise < void > {
106
- await this . reservationStore . start ( )
107
- await this . discovery ?. start ( )
106
+ this . reservationStore . start ( )
108
107
109
108
await this . registrar . handle ( RELAY_V2_STOP_CODEC , ( data ) => {
110
109
void this . onStop ( data ) . catch ( err => {
@@ -117,12 +116,18 @@ export class CircuitRelayTransport implements Transport {
117
116
runOnTransientConnection : true
118
117
} )
119
118
119
+ await this . discovery ?. start ( )
120
+
120
121
this . started = true
121
122
}
122
123
124
+ afterStart ( ) : void {
125
+ this . discovery ?. afterStart ( )
126
+ }
127
+
123
128
async stop ( ) : Promise < void > {
124
129
this . discovery ?. stop ( )
125
- await this . reservationStore . stop ( )
130
+ this . reservationStore . stop ( )
126
131
await this . registrar . unhandle ( RELAY_V2_STOP_CODEC )
127
132
128
133
this . started = false
You can’t perform that action at this time.
0 commit comments