serum-vial
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -22,3 +22,3 @@ "use strict"; | ||
const minionWorker = new worker_threads_1.Worker(path_1.default.resolve(__dirname, 'minion.js'), { | ||
workerData: { nodeEndpoint, port, markets } | ||
workerData: { nodeEndpoint, port, markets, minionNumber: i } | ||
}); | ||
@@ -25,0 +25,0 @@ minionWorker.on('error', (err) => { |
@@ -354,6 +354,19 @@ "use strict"; | ||
} | ||
const { port, nodeEndpoint, markets } = worker_threads_1.workerData; | ||
const { port, nodeEndpoint, markets, minionNumber } = worker_threads_1.workerData; | ||
const minion = new Minion(nodeEndpoint, markets); | ||
let lastPublishTimestamp = new Date(); | ||
if (minionNumber === 0) { | ||
setInterval(() => { | ||
const noDataPublishedForSeconds = (new Date().valueOf() - lastPublishTimestamp.valueOf()) / 1000; | ||
if (noDataPublishedForSeconds > 30) { | ||
logger_1.logger.log('info', `No market data published for prolonged time`, { | ||
lastPublishTimestamp: lastPublishTimestamp.toISOString(), | ||
noDataPublishedForSeconds | ||
}); | ||
} | ||
}, 15 * 1000).unref(); | ||
} | ||
minion.start(port).then(() => { | ||
helpers_1.serumDataChannel.onmessage = (message) => { | ||
lastPublishTimestamp = new Date(); | ||
minion.processMessages(message.data); | ||
@@ -360,0 +373,0 @@ }; |
@@ -46,2 +46,17 @@ "use strict"; | ||
}); | ||
let start = process.hrtime(); | ||
const interval = 600; | ||
// based on https://github.com/tj/node-blocked/blob/master/index.js | ||
setInterval(() => { | ||
const delta = process.hrtime(start); | ||
const nanosec = delta[0] * 1e9 + delta[1]; | ||
const ms = nanosec / 1e6; | ||
const n = ms - interval; | ||
if (n > 200) { | ||
logger_1.logger.log('info', `Event loop blocked for ${Math.round(n)} ms.`, { | ||
market: this._options.marketName | ||
}); | ||
} | ||
start = process.hrtime(); | ||
}, interval).unref(); | ||
for await (const notification of rpcClient.streamAccountsNotification(market, this._options.marketName)) { | ||
@@ -48,0 +63,0 @@ if (started === false) { |
{ | ||
"name": "serum-vial", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=15" |
@@ -31,3 +31,3 @@ import os from 'os' | ||
const minionWorker = new Worker(path.resolve(__dirname, 'minion.js'), { | ||
workerData: { nodeEndpoint, port, markets } | ||
workerData: { nodeEndpoint, port, markets, minionNumber: i } | ||
}) | ||
@@ -34,0 +34,0 @@ |
@@ -433,8 +433,29 @@ import { getLayoutVersion, Market } from '@project-serum/serum' | ||
const { port, nodeEndpoint, markets } = workerData as { port: number; nodeEndpoint: string; markets: SerumMarket[] } | ||
const { port, nodeEndpoint, markets, minionNumber } = workerData as { | ||
port: number | ||
nodeEndpoint: string | ||
markets: SerumMarket[] | ||
minionNumber: number | ||
} | ||
const minion = new Minion(nodeEndpoint, markets) | ||
let lastPublishTimestamp = new Date() | ||
if (minionNumber === 0) { | ||
setInterval(() => { | ||
const noDataPublishedForSeconds = (new Date().valueOf() - lastPublishTimestamp.valueOf()) / 1000 | ||
if (noDataPublishedForSeconds > 30) { | ||
logger.log('info', `No market data published for prolonged time`, { | ||
lastPublishTimestamp: lastPublishTimestamp.toISOString(), | ||
noDataPublishedForSeconds | ||
}) | ||
} | ||
}, 15 * 1000).unref() | ||
} | ||
minion.start(port).then(() => { | ||
serumDataChannel.onmessage = (message) => { | ||
lastPublishTimestamp = new Date() | ||
minion.processMessages(message.data) | ||
@@ -441,0 +462,0 @@ } |
@@ -67,2 +67,21 @@ import { Market } from '@project-serum/serum' | ||
let start = process.hrtime() | ||
const interval = 600 | ||
// based on https://github.com/tj/node-blocked/blob/master/index.js | ||
setInterval(() => { | ||
const delta = process.hrtime(start) | ||
const nanosec = delta[0] * 1e9 + delta[1] | ||
const ms = nanosec / 1e6 | ||
const n = ms - interval | ||
if (n > 200) { | ||
logger.log('info', `Event loop blocked for ${Math.round(n)} ms.`, { | ||
market: this._options.marketName | ||
}) | ||
} | ||
start = process.hrtime() | ||
}, interval).unref() | ||
for await (const notification of rpcClient.streamAccountsNotification(market, this._options.marketName)) { | ||
@@ -69,0 +88,0 @@ if (started === false) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
303782
4475