-
Notifications
You must be signed in to change notification settings - Fork 6
/
doc.go
52 lines (33 loc) · 1.35 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Package electrum provides an Electrum protocol client implementation.
The client supports two kind of operations, synchronous and asynchronous; for simplicity must
methods are exported as sync operations and only long running methods, i.e. subscriptions,
are exported as asynchronous.
Subscriptions take a context object that allows the client to cancel/close an instance at any
given time; subscriptions also returned a channel for data transfer, the channel will be
automatically closed by the client instance when the subscription is terminated.
The client supports TCP and TSL connections.
Creating a Client
First start a new client instance
client, _ := electrum.New(&electrum.Options{
Address: "node.xbt.eu:50002",
KeepAlive: true,
})
Synchronous Operations
Execute operations as regular methods
version, _ := client.ServerVersion()
Subscriptions
Get notifications using regular channels and context
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
defer cancel()
headers, _ := client.NotifyBlockHeaders(ctx)
for header := range headers {
// Use header
}
Terminating a Client
When done with the client instance free-up resources and terminate network communications
client.Close();
Protocol specification is available at:
http://docs.electrum.org/en/latest/protocol.html
*/
package electrum