-
Notifications
You must be signed in to change notification settings - Fork 0
/
responses.go
112 lines (97 loc) · 3.18 KB
/
responses.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Copyright 2019 Insolar Technologies GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package requester
import (
"time"
)
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
Error *Error `json:"error,omitempty"`
}
type Error struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data Data `json:"data,omitempty"`
}
func (e *Error) Error() string {
return e.Message
}
type Data struct {
Trace []string `json:"trace,omitempty"`
TraceID string `json:"traceID,omitempty"`
RequestReference string `json:"requestReference,omitempty"`
}
type ContractResponse struct {
Response
Result *ContractResult `json:"result,omitempty"`
}
type ContractResult struct {
CallResult interface{} `json:"callResult,omitempty"`
RequestReference string `json:"requestReference,omitempty"`
TraceID string `json:"traceID,omitempty"`
}
type seedResponse struct {
Seed string `json:"seed"`
TraceID string `json:"traceID"`
}
type rpcSeedResponse struct {
Response
Result seedResponse `json:"result"`
}
// SeedReply is reply for Seed service requests.
type SeedReply struct {
Seed []byte `json:"seed"`
TraceID string `json:"traceID"`
}
type rpcStatusResponse struct {
Response
Result StatusResponse `json:"result"`
}
type Node struct {
Reference string `json:"reference"`
Role string `json:"role"`
IsWorking bool `json:"isWorking"`
ID uint32 `json:"id"`
}
// StatusResponse represents response from rpc on node.getStatus method
type StatusResponse struct {
NetworkState string `json:"networkState"`
Origin Node `json:"origin"`
ActiveListSize int `json:"activeListSize"`
WorkingListSize int `json:"workingListSize"`
Nodes []Node `json:"nodes"`
PulseNumber uint32 `json:"pulseNumber"`
NetworkPulseNumber uint32 `json:"networkPulseNumber"`
Entropy []byte `json:"entropy"`
Version string `json:"version"`
Timestamp time.Time `json:"timestamp"`
StartTime time.Time `json:"startTime"`
}
// InfoResponse represents response from rpc on network.getInfo method
type InfoResponse struct {
RootDomain string `json:"rootDomain"`
RootMember string `json:"rootMember"`
MigrationAdminMember string `json:"migrationAdminMember"`
FeeMember string `json:"feeMember"`
MigrationDaemonMembers []string `json:"migrationDaemonMembers"`
NodeDomain string `json:"nodeDomain"`
TraceID string `json:"traceID"`
}
type rpcInfoResponse struct {
Response
Result InfoResponse `json:"result"`
}