-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.go
More file actions
41 lines (38 loc) · 825 Bytes
/
utility.go
File metadata and controls
41 lines (38 loc) · 825 Bytes
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
package net
import (
"sync"
"github.com/buger/jsonparser"
)
//PrepareTable return the account sequence and table NameInDB
func PrepareTable(client *Client, name string) (uint32, string, error) {
w := new(sync.WaitGroup)
w.Add(2)
var seq uint32 = 0
nameInDB := ""
err := error(nil)
go func() {
defer w.Done()
info, errTmp := client.GetAccountInfo(client.Auth.Address)
if errTmp != nil {
err = errTmp
return
}
sequence, errTmp := jsonparser.GetInt([]byte(info), "result", "account_data", "Sequence")
if errTmp != nil {
err = errTmp
return
}
seq = uint32(sequence)
}()
go func() {
defer w.Done()
nameInDBTmp, errTmp := client.GetNameInDB(client.Auth.Owner, name)
if errTmp != nil {
err = errTmp
return
}
nameInDB = nameInDBTmp
}()
w.Wait()
return seq, nameInDB, err
}