chart subscription fixes
This commit is contained in:
@@ -7,8 +7,10 @@ export const WIDE_PRICE_FORMAT = {decimals:38, width:512, signed:false}; // 38 d
|
||||
export function subOHLC( chainId, pool, period ) {
|
||||
const key = `${pool}|${period}`
|
||||
const ckey = `${chainId}|${key}`
|
||||
if (!(key in ohlcSubCounts) || ohlcSubCounts[ckey] === 0) {
|
||||
// console.log('subOHLC', chainId, pool, period, ckey, ohlcSubCounts[ckey])
|
||||
if (!(ckey in ohlcSubCounts) || ohlcSubCounts[ckey] === 0) {
|
||||
ohlcSubCounts[ckey] = 1
|
||||
console.log('subscribing OHLCs', chainId, key)
|
||||
socket.emit('subOHLCs', chainId, [key])
|
||||
} else
|
||||
ohlcSubCounts[ckey]++
|
||||
@@ -18,14 +20,17 @@ export function subOHLC( chainId, pool, period ) {
|
||||
export function unsubOHLC( chainId, pool, period ) {
|
||||
const key = `${pool}|${period}`
|
||||
const ckey = `${chainId}|${key}`
|
||||
// console.log('unsubOHLC', chainId, pool, period, ckey, ohlcSubCounts[ckey])
|
||||
if (!(ckey in ohlcSubCounts) || ohlcSubCounts[ckey] === 0) {
|
||||
console.error('overdecremented ohlc', pool, period)
|
||||
ohlcSubCounts[ckey] = 1
|
||||
} else {
|
||||
ohlcSubCounts[ckey]--
|
||||
if (ohlcSubCounts[key] === 0)
|
||||
if (ohlcSubCounts[ckey] === 0) {
|
||||
console.log('unsubscribing OHLCs', chainId, key)
|
||||
// noinspection JSCheckFunctionSignatures
|
||||
socket.emit('unsubOHLCs', chainId, [key])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user