Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async start() {
const dispatcher = dynamicMessageDispatcher({
listening: this.onListening,
action_trace: this.onAction,
progress: this.onProgress
})
console.log("Engine starting")
this.stream = await this.client.streamActionTraces(
{
accounts: "therealkarma",
action_names: "transfer"
},
dispatcher,
{
// You can use the `with_progress` to be sure to commit
// actions at least each 10 blocks. This is useful if your stream
// is low traffic so you don't need to wait until the next
public async start() {
console.log("Engine starting")
this.stream = await this.client.streamTableRows(
{
code: "eosio",
table: "global",
scope: "eosio"
},
dynamicMessageDispatcher({
listening: this.onListening,
table_delta: this.onTableDelta,
table_snapshot: this.onTableSnapshot,
progress: this.onProgress
}),
{
listen: true,
fetch: true,
// We use progress to display the current state of the table at a regular interval
with_progress: 50
}
)
}
"Notice how `Buy RAM` and `RAM cost` happens in random order, due to using 2 independent streams."
)
await waitFor(60000)
await buyRamStream.close()
await ramStream.close()
console.log("")
const mergedData = {
accounts: "eosio|eosio.token",
action_names: "buyrambytes|transfer",
receivers: "eosio|eosio.token|eosio.ram"
}
const mergedStream: Stream = await client.streamActionTraces(
mergedData,
dynamicMessageDispatcher({
listening: onListeningFactory("merged"),
action_trace: onMergedAction
})
)
console.log(
"Notice how `Buy RAM` is always before `RAM cost` thanks to the strict ordering of a single stream."
)
await waitFor(60000)
await mergedStream.close()
client.release()
}