Skip to content

Commit 185f9cd

Browse files
committed
Update to latest gRPC
This involves updating the generator script to install and use an additional tool, as two generator are now used (one for protobuf messages, and another for defining the gRPC services).
1 parent 4941af1 commit 185f9cd

File tree

7 files changed

+4552
-4309
lines changed

7 files changed

+4552
-4309
lines changed

go.mod

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ require (
2626
github.com/decred/dcrd/wire v1.5.0
2727
github.com/decred/go-socks v1.1.0
2828
github.com/decred/slog v1.2.0
29-
github.com/golang/protobuf v1.4.2
3029
github.com/gorilla/websocket v1.4.2
3130
github.com/jessevdk/go-flags v1.4.1-0.20200711081900-c17162fe8fd7
3231
github.com/jrick/bitset v1.0.0
3332
github.com/jrick/logrotate v1.0.0
3433
github.com/jrick/wsrpc/v2 v2.3.4
3534
go.etcd.io/bbolt v1.3.5
36-
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
35+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
3736
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
38-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
39-
google.golang.org/grpc v1.32.0
40-
google.golang.org/protobuf v1.23.0
37+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
38+
google.golang.org/grpc v1.45.0
39+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0
40+
google.golang.org/protobuf v1.27.1
4141
)
4242

4343
require (
@@ -47,8 +47,9 @@ require (
4747
github.com/decred/base58 v1.0.3 // indirect
4848
github.com/decred/dcrd/database/v3 v3.0.0 // indirect
4949
github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 // indirect
50-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
51-
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
52-
golang.org/x/text v0.3.3 // indirect
53-
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
50+
github.com/golang/protobuf v1.5.2 // indirect
51+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
52+
golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 // indirect
53+
golang.org/x/text v0.3.7 // indirect
54+
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
5455
)

go.sum

Lines changed: 67 additions & 11 deletions
Large diffs are not rendered by default.

internal/rpc/rpcserver/server.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,16 @@ func decodeHashes(in [][]byte) ([]*chainhash.Hash, error) {
167167

168168
// versionServer provides RPC clients with the ability to query the RPC server
169169
// version.
170-
type versionServer struct{}
170+
type versionServer struct {
171+
pb.UnimplementedVersionServiceServer
172+
}
171173

172174
// walletServer provides wallet services for RPC clients.
173175
type walletServer struct {
174176
ready uint32 // atomic
175177
wallet *wallet.Wallet
176178
dialCSPPServer func(ctx context.Context, network, addr string) (net.Conn, error)
179+
pb.UnimplementedWalletServiceServer
177180
}
178181

179182
// loaderServer provides RPC clients with the ability to load and close wallets,
@@ -182,52 +185,62 @@ type loaderServer struct {
182185
ready uint32 // atomic
183186
loader *loader.Loader
184187
activeNet *netparams.Params
188+
pb.UnimplementedWalletLoaderServiceServer
185189
}
186190

187191
// seedServer provides RPC clients with the ability to generate secure random
188192
// seeds encoded in both binary and human-readable formats, and decode any
189193
// human-readable input back to binary.
190-
type seedServer struct{}
194+
type seedServer struct {
195+
pb.UnimplementedSeedServiceServer
196+
}
191197

192198
// accountMixerServer provides RPC clients with the ability to start/stop the
193199
// account mixing privacy service.
194200
type accountMixerServer struct {
195201
ready uint32 // atomic
196202
loader *loader.Loader
203+
pb.UnimplementedAccountMixerServiceServer
197204
}
198205

199206
// ticketbuyerServer provides RPC clients with the ability to start/stop the
200207
// automatic ticket buyer service.
201208
type ticketbuyerV2Server struct {
202209
ready uint32 // atomic
203210
loader *loader.Loader
211+
pb.UnimplementedTicketBuyerV2ServiceServer
204212
}
205213

206214
type agendaServer struct {
207215
ready uint32 // atomic
208216
activeNet *chaincfg.Params
217+
pb.UnimplementedAgendaServiceServer
209218
}
210219

211220
type votingServer struct {
212221
ready uint32 // atomic
213222
wallet *wallet.Wallet
223+
pb.UnimplementedVotingServiceServer
214224
}
215225

216226
// messageVerificationServer provides RPC clients with the ability to verify
217227
// that a message was signed using the private key of a particular address.
218228
type messageVerificationServer struct {
219229
chainParams *chaincfg.Params
230+
pb.UnimplementedMessageVerificationServiceServer
220231
}
221232

222233
type decodeMessageServer struct {
223234
chainParams *chaincfg.Params
235+
pb.UnimplementedDecodeMessageServiceServer
224236
}
225237

226238
// networkServer provices RPC clients with the ability to perform network
227239
// related calls that are not necessarily used or backed by the wallet itself.
228240
type networkServer struct {
229241
ready uint32 // atomic
230242
wallet *wallet.Wallet
243+
pb.UnimplementedNetworkServiceServer
231244
}
232245

233246
// Singleton implementations of each service. Not all services are immediately

rpc/regen.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#!/bin/sh
22

3-
build_protoc_gen_go() {
3+
build_tools() {
44
mkdir -p bin
55
export GOBIN=$PWD/bin
6-
GO111MODULE=on go install github.com/golang/protobuf/protoc-gen-go
6+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
7+
go install google.golang.org/protobuf/cmd/protoc-gen-go
78
}
89

910
generate() {
10-
protoc -I. api.proto --go_out=plugins=grpc:walletrpc --go_opt=paths=source_relative
11+
protoc -I. api.proto --go_out=walletrpc --go-grpc_out=walletrpc \
12+
--go_opt=paths=source_relative --go-grpc_opt=paths=source_relative
1113

1214
# fix uid mapping on files created within the container
1315
[ -n "$UID" ] && chown -R $UID . 2>/dev/null
1416
}
1517

16-
(cd tools && build_protoc_gen_go)
18+
(cd tools && build_tools)
1719
PATH=$PWD/tools/bin:$PATH generate

rpc/tools/tools.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//go:build ignore
2-
// +build ignore
1+
//go:build tools
32

43
package tools
54

65
import (
7-
_ "github.com/golang/protobuf/protoc-gen-go"
6+
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
7+
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
88
)

0 commit comments

Comments
 (0)