-
Notifications
You must be signed in to change notification settings - Fork 43
/
join-thread.go
44 lines (36 loc) · 963 Bytes
/
join-thread.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
package main
import (
"context"
"fmt"
"os"
ma "github.com/multiformats/go-multiaddr"
tc "github.com/textileio/go-threads/api/client"
"github.com/textileio/go-threads/core/thread"
"github.com/textileio/textile/api/common"
"github.com/textileio/textile/cmd"
"google.golang.org/grpc"
)
func main() {
addr := os.Args[2]
key := os.Args[3]
m1, _ := ma.NewMultiaddr(addr)
var threads *tc.Client
host := "127.0.0.1:3006"
auth := common.Credentials{}
var opts []grpc.DialOption
threadstarget := host
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithPerRPCCredentials(auth))
threads, err := tc.NewClient(threadstarget, opts...)
if err != nil {
cmd.Fatal(err)
}
threadCtx := context.Background()
k, err := thread.KeyFromString(key)
threads.NewDBFromAddr(threadCtx, m1, k)
db, err := threads.ListDBs(threadCtx)
for k, v := range db {
fmt.Println("looping through thread id: ", k)
fmt.Println("db info: ", v)
}
}