-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapi.proto
138 lines (114 loc) · 3.25 KB
/
api.proto
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Copyright (c) 2019 IoTeX
// This program is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with this program. If
// not, see <http://www.gnu.org/licenses/>.
// To compile the proto, run:
// protoc --go_out=plugins=grpc:. *.proto
syntax = "proto3";
package api;
option go_package = "github.com/iotexproject/iotex-election/pb/api";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "election/election.proto";
// The APIService service definition
service APIService {
// get the blockchain meta data
rpc getMeta(google.protobuf.Empty) returns (ChainMeta) {}
// get candidates
rpc getCandidates(GetCandidatesRequest) returns (CandidateResponse) {}
// get candidate by name
rpc getCandidateByName(GetCandidateByNameRequest) returns (Candidate) {}
// get buckets by candidate
rpc getBucketsByCandidate(GetBucketsByCandidateRequest) returns (BucketResponse) {}
// get Buckets
rpc getBuckets(GetBucketsRequest) returns (BucketResponse) {}
// health endpoint
rpc isHealth(google.protobuf.Empty) returns (HealthCheckResponse) {}
// get raw data by height
rpc getRawData(GetRawDataRequest) returns (RawDataResponse) {}
// get proof for a given account
rpc getProof(ProofRequest) returns (ProofResponse) {
option (google.api.http) = {
get: "/get_proof/{account}"
};
}
}
message ChainMeta {
string height = 1;
uint64 totalCandidates = 2;
string totalVotedStakes = 3;
string totalVotes = 4;
}
message Bucket {
// hex string
string voter = 1;
string votes = 2;
string weightedVotes = 3;
// human readable duration
string remainingDuration = 4;
}
message Candidate {
string name = 1;
// hex string
string address = 2;
string totalWeightedVotes = 3;
string selfStakingTokens = 4;
string operatorAddress = 5;
string rewardAddress = 6;
}
message GetCandidatesRequest {
string height = 1;
uint32 offset = 2;
uint32 limit =3;
}
message GetCandidateByNameRequest {
string name = 1;
string height = 2;
}
message GetBucketsByCandidateRequest {
string name = 1;
string height = 2;
uint32 offset = 3;
uint32 limit = 4;
}
message GetBucketsRequest {
string height = 1;
uint32 offset = 2;
uint32 limit = 3;
}
message HealthCheckResponse {
enum Status {
STARTING = 0;
ACTIVE = 1;
INACTIVE = 2;
}
Status status = 1;
}
message CandidateResponse {
repeated Candidate candidates = 1;
}
message BucketResponse {
repeated Bucket buckets = 1;
}
message GetRawDataRequest {
string height = 1;
}
message RawDataResponse {
google.protobuf.Timestamp timestamp = 1;
repeated election.Bucket buckets = 2;
repeated election.Registration registrations = 3;
}
message ProofRequest {
string account = 1;
}
message ProofResponse {
string amount = 1;
string deadline = 2;
string proof = 3;
}