Skip to content

Commit e7ee29b

Browse files
authored
Merge pull request #403 from guggero/docker-rpc
looprpc: generate protos with docker
2 parents df5924f + 803773b commit e7ee29b

16 files changed

+4262
-2372
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@ install:
7474
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loopd
7575

7676
rpc:
77-
@$(call print, "Compiling RPC protos.")
78-
cd looprpc; ./gen_protos.sh
77+
@$(call print, "Compiling protos.")
78+
cd ./looprpc; ./gen_protos_docker.sh
79+
80+
rpc-check: rpc
81+
@$(call print, "Verifying protos.")
82+
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with correct version!"; git status; git diff; exit 1; fi

cmd/loop/loopout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ func loopOut(ctx *cli.Context) error {
203203
}
204204

205205
fmt.Printf("Swap initiated\n")
206-
fmt.Printf("ID: %v\n", resp.Id)
207-
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress)
206+
fmt.Printf("ID: %x\n", resp.IdBytes)
207+
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress) // nolint:staticcheck
208208
if resp.ServerMessage != "" {
209209
fmt.Printf("Server message: %v\n", resp.ServerMessage)
210210
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ require (
2121
github.com/stretchr/testify v1.7.0
2222
github.com/urfave/cli v1.20.0
2323
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
24-
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c
2524
google.golang.org/grpc v1.29.1
25+
google.golang.org/protobuf v1.23.0
2626
gopkg.in/macaroon-bakery.v2 v2.0.1
2727
gopkg.in/macaroon.v2 v2.1.0
2828
)

loopd/swapclient_server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
121121
}
122122

123123
switch {
124-
case in.LoopOutChannel != 0 && len(in.OutgoingChanSet) > 0:
124+
case in.LoopOutChannel != 0 && len(in.OutgoingChanSet) > 0: // nolint:staticcheck
125125
return nil, errors.New("loop_out_channel and outgoing_" +
126126
"chan_ids are mutually exclusive")
127127

128-
case in.LoopOutChannel != 0:
129-
req.OutgoingChanSet = loopdb.ChannelSet{in.LoopOutChannel}
128+
case in.LoopOutChannel != 0: // nolint:staticcheck
129+
req.OutgoingChanSet = loopdb.ChannelSet{in.LoopOutChannel} // nolint:staticcheck
130130

131131
default:
132132
req.OutgoingChanSet = in.OutgoingChanSet
@@ -540,9 +540,9 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
540540

541541
if req.ExternalHtlc {
542542
response.HtlcAddressNp2Wsh = swapInfo.HtlcAddressNP2WSH.String()
543-
response.HtlcAddress = response.HtlcAddressNp2Wsh
543+
response.HtlcAddress = response.HtlcAddressNp2Wsh // nolint:staticcheck
544544
} else {
545-
response.HtlcAddress = response.HtlcAddressP2Wsh
545+
response.HtlcAddress = response.HtlcAddressP2Wsh // nolint:staticcheck
546546
}
547547

548548
return response, nil

looprpc/.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Language: Proto
3+
BasedOnStyle: Google
4+
IndentWidth: 4
5+
AllowShortFunctionsOnASingleLine: None
6+
SpaceBeforeParens: Always
7+
CompactNamespaces: false

looprpc/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM golang:1.15.6-buster
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
protobuf-compiler='3.6*' \
6+
clang-format='1:7.0*'
7+
8+
# We don't want any default values for these variables to make sure they're
9+
# explicitly provided by parsing the go.mod file. Otherwise we might forget to
10+
# update them here if we bump the versions.
11+
ARG PROTOC_GEN_VERSION
12+
ARG GRPC_GATEWAY_VERSION
13+
14+
RUN cd /tmp \
15+
&& export GO111MODULE=on \
16+
&& go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_VERSION} \
17+
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
18+
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION}
19+
20+
WORKDIR /build
21+
22+
CMD ["/bin/bash", "/build/looprpc/gen_protos.sh"]

0 commit comments

Comments
 (0)