We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ac3165 commit 9590ca5Copy full SHA for 9590ca5
example/subscribe.js
@@ -0,0 +1,18 @@
1
+const ElectrumClient = require('..')
2
+const sleep = (ms) => new Promise((resolve,_) => setTimeout(() => resolve(ms), ms))
3
+
4
+const main = async () => {
5
+ const ecl = new ElectrumClient(995, 'btc.smsys.me', 'tls')
6
+ ecl.subscribe.on('server.peers.subscribe', console.log)
7
+ ecl.subscribe.on('blockchain.numblocks.subscribe', console.log)
8
+ ecl.subscribe.on('blockchain.headers.subscribe', console.log)
9
+ await ecl.connect()
10
+ const p1 = await ecl.serverPeers_subscribe()
11
+ const p2 = await ecl.blockchainHeaders_subscribe()
12
+ const p3 = await ecl.blockchainNumblocks_subscribe()
13
+ while(true){
14
+ await sleep(1000)
15
+ }
16
+ await ecl.close()
17
+}
18
+main()
0 commit comments