Skip to content

Commit

Permalink
Merge pull request #389 from wowica/docs/update-mempool-example
Browse files Browse the repository at this point in the history
Update mempool example to v6.x
  • Loading branch information
KtorZ authored Jul 1, 2024
2 parents 001587d + 071ecd7 commit 504c23b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions docs/content/mini-protocols/local-tx-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,27 @@ const client = new WebSocket("ws://localhost:1337");
// Helper function
function rpc(method, params) {
client.send(JSON.stringify({
jsonrpc: "2.0",
jsonrpc: '2.0',
method,
params
}));
}

client.on('message', e => {
const next = JSON.parse(e).result;
if (next.transaction === null) {
client.close();
const message = JSON.parse(e);
if (message?.result?.transaction === null) {
rpc('acquireMempool');
} else {
console.log(next.transaction);
rpc("nextTransaction");
console.log(message.result);
// Returns transaction id
rpc('nextTransaction');
// Returns all transaction information
// rpc("nextTransaction", { fields: "all" });
}
});

client.once('open', () => {
rpc("acquireMempool");
rpc('acquireMempool');
});
```
Expand Down

0 comments on commit 504c23b

Please sign in to comment.