File tree 3 files changed +19
-5
lines changed
3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -994,6 +994,11 @@ class OrderBook extends EventEmitter {
994
994
if ( peer . isPairActive ( pairId ) ) {
995
995
return false ; // don't verify a pair that is already active
996
996
}
997
+ if ( ! this . tradingPairs . has ( pairId ) ) {
998
+ // if we don't support the trading pair locally, then we don't want to verify or activate it
999
+ return false ;
1000
+ }
1001
+
997
1002
const [ baseCurrency , quoteCurrency ] = pairId . split ( '/' ) ;
998
1003
const peerCurrenciesEnabled = ! peer . disabledCurrencies . has ( baseCurrency )
999
1004
&& ! peer . disabledCurrencies . has ( quoteCurrency ) ;
@@ -1050,7 +1055,9 @@ class OrderBook extends EventEmitter {
1050
1055
1051
1056
// activate verified currencies
1052
1057
currenciesToVerify . forEach ( ( swappable , currency ) => {
1053
- if ( swappable || ! this . strict ) { // always activate currencies if not in strict mode
1058
+ // in strict mode, we only activate "swappable" currencies where a route to peer is possible or a sanity swap has completed
1059
+ // in non-strict mode, we activate any currency which we also support locally
1060
+ if ( swappable || ( ! this . strict && this . swaps . swapClientManager . has ( currency ) ) ) {
1054
1061
peer . activateCurrency ( currency ) ;
1055
1062
}
1056
1063
} ) ;
Original file line number Diff line number Diff line change @@ -247,6 +247,15 @@ class SwapClientManager extends EventEmitter {
247
247
return this . swapClients . get ( currency ) ;
248
248
}
249
249
250
+ /**
251
+ * Returns whether the swap client manager has a client for a given currency.
252
+ * @param currency the currency that the swap client is linked to.
253
+ * @returns `true` if a swap client exists, false otherwise.
254
+ */
255
+ public has = ( currency : string ) : boolean => {
256
+ return this . swapClients . has ( currency ) ;
257
+ }
258
+
250
259
/** Gets the type of swap client for a given currency. */
251
260
public getType = ( currency : string ) => {
252
261
return this . swapClients . get ( currency ) ?. type ;
Original file line number Diff line number Diff line change @@ -175,13 +175,11 @@ describe('OrderBook', () => {
175
175
test ( 'nosanityswaps enabled adds pairs and requests orders' , async ( ) => {
176
176
orderbook [ 'nosanityswaps' ] = true ;
177
177
await orderbook [ 'verifyPeerPairs' ] ( peer ) ;
178
- expect ( mockActivateCurrency ) . toHaveBeenCalledTimes ( 3 ) ;
178
+ expect ( mockActivateCurrency ) . toHaveBeenCalledTimes ( 2 ) ;
179
179
expect ( mockActivateCurrency ) . toHaveBeenCalledWith ( 'BTC' ) ;
180
180
expect ( mockActivateCurrency ) . toHaveBeenCalledWith ( 'LTC' ) ;
181
- expect ( mockActivateCurrency ) . toHaveBeenCalledWith ( 'WETH' ) ;
182
- expect ( mockActivatePair ) . toHaveBeenCalledTimes ( 2 ) ;
181
+ expect ( mockActivatePair ) . toHaveBeenCalledTimes ( 1 ) ;
183
182
expect ( mockActivatePair ) . toHaveBeenCalledWith ( advertisedPairs [ 0 ] ) ;
184
- expect ( mockActivatePair ) . toHaveBeenCalledWith ( advertisedPairs [ 1 ] ) ;
185
183
} ) ;
186
184
187
185
test ( 'isPeerCurrencySupported returns true for a known currency with matching identifiers' , async ( ) => {
You can’t perform that action at this time.
0 commit comments