-
Notifications
You must be signed in to change notification settings - Fork 13
/
api_liststreams.go
48 lines (41 loc) · 1.32 KB
/
api_liststreams.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
package multichain
import (
"strings"
)
// Returns information about streams created on the blockchain.
// Pass a slice of stream names, refs or creation txids to retrieve information about respective streams.
// Extra fields are shown for streams to which this node has subscribed.
func (client *Client) ListStreams(streams []string, verbose bool) (Response, error) {
return client.listStreams(strings.Join(streams, ","), verbose)
}
// Returns information about all streams created on the blockchain.
// Extra fields are shown for streams to which this node has subscribed.
func (client *Client) ListAllStreams(verbose bool) (Response, error) {
return client.listStreams("*", verbose)
}
func (client *Client) listStreams(streams string, verbose bool) (Response, error) {
params := getListStreamsParams(streams, verbose)
return client.Post(
map[string]interface{}{
"jsonrpc": "1.0",
"id": CONST_ID,
"method": "liststreams",
"params": params,
},
)
}
func getListStreamsParams(streams string, verbose bool) []interface{} {
if len(streams) == 0 {
streams = "*"
}
params := []interface{}{}
var streamsParam interface{}
if streams == "*" {
streamsParam = streams
} else {
streamsParam = strings.Split(streams, ",")
}
params = append(params, streamsParam)
params = append(params, verbose)
return params
}