|
|
@@ -15,6 +15,8 @@ import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
|
import { sliceAccumulatorUpdateData } from "@pythnetwork/price-service-sdk";
|
|
|
import { Logger } from "pino";
|
|
|
|
|
|
+const HEALTH_CHECK_TIMEOUT_SECONDS = 60;
|
|
|
+
|
|
|
export class SolanaPriceListener extends ChainPriceListener {
|
|
|
constructor(
|
|
|
private pythSolanaReceiver: PythSolanaReceiver,
|
|
|
@@ -35,7 +37,17 @@ export class SolanaPriceListener extends ChainPriceListener {
|
|
|
const blockTime = await this.pythSolanaReceiver.connection.getBlockTime(
|
|
|
slot
|
|
|
);
|
|
|
- if (blockTime === null || blockTime < Date.now() / 1000 - 50) {
|
|
|
+ if (
|
|
|
+ blockTime === null ||
|
|
|
+ blockTime < Date.now() / 1000 - HEALTH_CHECK_TIMEOUT_SECONDS
|
|
|
+ ) {
|
|
|
+ if (blockTime !== null) {
|
|
|
+ this.logger.info(
|
|
|
+ `Solana connection is behind by ${
|
|
|
+ Date.now() / 1000 - blockTime
|
|
|
+ } seconds`
|
|
|
+ );
|
|
|
+ }
|
|
|
throw new Error("Solana connection is unhealthy");
|
|
|
}
|
|
|
}
|