Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const wsStream = await client.streamHeadInfo((message: InboundMessage) => {
if (message.type === InboundMessageType.ERROR) {
console.log("WebSocket stream error.", message.data)
return
}
if (message.type === InboundMessageType.LISTENING) {
console.log("WebSocket stream is now listening.")
}
if (message.type === InboundMessageType.HEAD_INFO) {
console.log("WebSocket stream data.", JSON.stringify(message.data))
// Mark latest location where we want to start back at
wsStream.mark({ atBlockNum: message.data.head_block_num })
}
})
const stream = await client.streamHeadInfo((message: InboundMessage) => {
if (message.type === InboundMessageType.LISTENING) {
console.log(prettifyJson(message.data))
return
}
if (message.type === InboundMessageType.HEAD_INFO) {
console.log(prettifyJson(message.data))
return
}
})