-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from boschresearch/311-2-add-protobuf-adapter
Implement protobuf adapter for wire serialization
- Loading branch information
Showing
31 changed files
with
4,427 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,20 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check vanity import | ||
run: .scripts/check-vanity-imports.sh $GITHUB_WORKSPACE | ||
- name: Lint | ||
|
||
- name: Lint golang files | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.43 | ||
|
||
- name: Lint proto files | ||
uses: plexsystems/[email protected] | ||
with: | ||
configDirectory: . | ||
|
||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
lint: | ||
ignores: | ||
# Sometimes, when variable names are long line length exceeds 80 char. | ||
- id: MAX_LINE_LENGTH | ||
files: | ||
- wire/protobuf/wire.proto | ||
|
||
# Some fields with repeated type intentionally have non plural names. | ||
# Eg: balance, index_map etc., | ||
- id: REPEATED_FIELD_NAMES_PLURALIZED | ||
files: | ||
- wire/protobuf/wire.proto | ||
|
||
rules: | ||
|
||
# Enable a few additional linters, that are not part of official style | ||
# guide for protonbuf. | ||
add: | ||
- MESSAGES_HAVE_COMMENT | ||
- FILE_HAS_COMMENT | ||
- SYNTAX_CONSISTENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 - See NOTICE file for copyright holders. | ||
// | ||
// 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 protobuf | ||
|
||
import ( | ||
"time" | ||
|
||
"perun.network/go-perun/wire" | ||
) | ||
|
||
func fromPingMsg(msg *wire.PingMsg) *Envelope_PingMsg { | ||
protoMsg := &PingMsg{} | ||
protoMsg.Created = msg.Created.UnixNano() | ||
return &Envelope_PingMsg{protoMsg} | ||
} | ||
|
||
func fromPongMsg(msg *wire.PongMsg) *Envelope_PongMsg { | ||
protoMsg := &PongMsg{} | ||
protoMsg.Created = msg.Created.UnixNano() | ||
return &Envelope_PongMsg{protoMsg} | ||
} | ||
|
||
func fromShutdownMsg(msg *wire.ShutdownMsg) *Envelope_ShutdownMsg { | ||
protoMsg := &ShutdownMsg{} | ||
protoMsg.Reason = msg.Reason | ||
return &Envelope_ShutdownMsg{protoMsg} | ||
} | ||
|
||
func toPingMsg(protoMsg *Envelope_PingMsg) (msg *wire.PingMsg) { | ||
msg = &wire.PingMsg{} | ||
msg.Created = time.Unix(0, protoMsg.PingMsg.Created) | ||
return msg | ||
} | ||
|
||
func toPongMsg(protoEnvMsg *Envelope_PongMsg) (msg *wire.PongMsg) { | ||
msg = &wire.PongMsg{} | ||
msg.Created = time.Unix(0, protoEnvMsg.PongMsg.Created) | ||
return msg | ||
} | ||
|
||
func toShutdownMsg(protoEnvMsg *Envelope_ShutdownMsg) (msg *wire.ShutdownMsg) { | ||
msg = &wire.ShutdownMsg{} | ||
msg.Reason = protoEnvMsg.ShutdownMsg.Reason | ||
return msg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2022 - See NOTICE file for copyright holders. | ||
// | ||
// 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 protobuf implements the wire serializer interface using the protocol | ||
// buffers serialization protocol. | ||
package protobuf // import "perun.network/go-perun/wire/protobuf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 - See NOTICE file for copyright holders. | ||
// | ||
// 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 protobuf | ||
|
||
// This command generates the bindings for serializing wire messages using | ||
// protocol buffers serialization protocol. | ||
// | ||
// It requires protoc and protoc-gen-go to be installed. | ||
|
||
//go:generate protoc --go_out=. wire.proto |
Oops, something went wrong.