/
rpc.go
56 lines (49 loc) · 1.39 KB
/
rpc.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
53
54
55
56
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc
import (
"context"
"github.com/33cn/chain33/types"
vt "github.com/33cn/plugin/plugin/dapp/valnode/types"
)
// IsSync query is sync
func (c *channelClient) IsSync(ctx context.Context, req *types.ReqNil) (*vt.IsHealthy, error) {
data, err := c.QueryConsensusFunc("tendermint", "IsHealthy", &types.ReqNil{})
if err != nil {
return nil, err
}
if resp, ok := data.(*vt.IsHealthy); ok {
return resp, nil
}
return nil, types.ErrDecode
}
// IsSync query is sync
func (c *Jrpc) IsSync(req *types.ReqNil, result *interface{}) error {
data, err := c.cli.IsSync(context.Background(), req)
if err != nil {
return err
}
*result = data.IsHealthy
return nil
}
// GetNodeInfo query node info
func (c *channelClient) GetNodeInfo(ctx context.Context, req *types.ReqNil) (*vt.ValNodeInfoSet, error) {
data, err := c.QueryConsensusFunc("tendermint", "NodeInfo", &types.ReqNil{})
if err != nil {
return nil, err
}
if resp, ok := data.(*vt.ValNodeInfoSet); ok {
return resp, nil
}
return nil, types.ErrDecode
}
// GetNodeInfo query node info
func (c *Jrpc) GetNodeInfo(req *types.ReqNil, result *interface{}) error {
data, err := c.cli.GetNodeInfo(context.Background(), req)
if err != nil {
return err
}
*result = data
return nil
}