Skip to content

Commit 156d8f6

Browse files
authored
Merge pull request #2304 from hirosystems/fix/snp-init
fix: SNP start
2 parents 9a159e1 + 961c66d commit 156d8f6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ async function init(): Promise<void> {
147147
});
148148

149149
const skipChainIdCheck = parseBoolean(process.env['SKIP_STACKS_CHAIN_ID_CHECK']);
150-
if (!skipChainIdCheck) {
150+
const snpEnabled = parseBoolean(process.env['SNP_EVENT_STREAMING']);
151+
if (!skipChainIdCheck && !snpEnabled) {
151152
const networkChainId = await getStacksNodeChainID();
152153
if (networkChainId !== configuredChainID) {
153154
const chainIdConfig = numberToHex(configuredChainID);
@@ -159,18 +160,20 @@ async function init(): Promise<void> {
159160
throw error;
160161
}
161162
}
162-
monitorCoreRpcConnection().catch(error => {
163-
logger.error(error, 'Error monitoring RPC connection');
164-
});
163+
if (!snpEnabled) {
164+
monitorCoreRpcConnection().catch(error => {
165+
logger.error(error, 'Error monitoring RPC connection');
166+
});
167+
}
165168

166-
const snpEnabled = parseBoolean(process.env['SNP_EVENT_STREAMING']);
167169
if (snpEnabled) {
168170
const lastRedisMsgId = await dbWriteStore.getLastIngestedSnpRedisMsgId();
169171
const snpStream = new SnpEventStreamHandler({
170172
lastMessageId: lastRedisMsgId,
171173
db: dbWriteStore,
172174
eventServer,
173175
});
176+
await snpStream.start();
174177
registerShutdownConfig({
175178
name: 'SNP client stream',
176179
handler: () => snpStream.stop(),

0 commit comments

Comments
 (0)