Commit f4f9cb40 authored by Janos Guljas's avatar Janos Guljas

move hanshake proto definitions into their own package

parent 2022d5b2
......@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. handshake.proto"
package handshake
import (
"fmt"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
)
......@@ -39,8 +38,8 @@ type Logger interface {
func (s *Service) Handshake(stream p2p.Stream) (i *Info, err error) {
w, r := protobuf.NewWriterAndReader(stream)
var resp ShakeHand
if err := w.WriteMsg(&ShakeHand{
var resp pb.ShakeHand
if err := w.WriteMsg(&pb.ShakeHand{
Address: s.overlay,
NetworkID: s.networkID,
}); err != nil {
......@@ -64,13 +63,13 @@ func (s *Service) Handle(stream p2p.Stream) (i *Info, err error) {
w, r := protobuf.NewWriterAndReader(stream)
defer stream.Close()
var req ShakeHand
var req pb.ShakeHand
if err := r.ReadMsg(&req); err != nil {
return nil, fmt.Errorf("handshake handler read message: %w", err)
}
s.logger.Tracef("handshake handler received request %s", req.Address)
if err := w.WriteMsg(&ShakeHand{
if err := w.WriteMsg(&pb.ShakeHand{
Address: s.overlay,
NetworkID: s.networkID,
}); err != nil {
......
......@@ -11,6 +11,7 @@ import (
"testing"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
)
......@@ -63,7 +64,7 @@ func TestHandshake(t *testing.T) {
stream2 := &StreamMock{readBuffer: &buffer2, writeBuffer: &buffer1}
w, _ := protobuf.NewWriterAndReader(stream2)
if err := w.WriteMsg(&ShakeHand{
if err := w.WriteMsg(&pb.ShakeHand{
Address: expectedInfo.Address,
NetworkID: expectedInfo.NetworkID,
Light: expectedInfo.Light,
......@@ -133,7 +134,7 @@ func TestHandle(t *testing.T) {
stream2 := &StreamMock{readBuffer: &buffer2, writeBuffer: &buffer1}
w, _ := protobuf.NewWriterAndReader(stream2)
if err := w.WriteMsg(&ShakeHand{
if err := w.WriteMsg(&pb.ShakeHand{
Address: node2Info.Address,
NetworkID: node2Info.NetworkID,
Light: node2Info.Light,
......@@ -151,7 +152,7 @@ func TestHandle(t *testing.T) {
}
_, r := protobuf.NewWriterAndReader(stream2)
var got ShakeHand
var got pb.ShakeHand
if err := r.ReadMsg(&got); err != nil {
t.Fatal(err)
}
......@@ -182,7 +183,7 @@ func TestHandle(t *testing.T) {
stream := &StreamMock{readBuffer: &buffer, writeBuffer: &buffer}
w, _ := protobuf.NewWriterAndReader(stream)
if err := w.WriteMsg(&ShakeHand{
if err := w.WriteMsg(&pb.ShakeHand{
Address: "node1",
NetworkID: 0,
Light: false,
......
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. handshake.proto"
// Package pb holds only Protocol Buffer definitions and generated code.
package pb
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: handshake.proto
package handshake
package pb
import (
fmt "fmt"
......@@ -83,7 +83,7 @@ func (m *ShakeHand) GetLight() bool {
}
func init() {
proto.RegisterType((*ShakeHand)(nil), "handshake.ShakeHand")
proto.RegisterType((*ShakeHand)(nil), "pb.ShakeHand")
}
func init() { proto.RegisterFile("handshake.proto", fileDescriptor_a77305914d5d202f) }
......@@ -91,15 +91,15 @@ func init() { proto.RegisterFile("handshake.proto", fileDescriptor_a77305914d5d2
var fileDescriptor_a77305914d5d202f = []byte{
// 148 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcf, 0x48, 0xcc, 0x4b,
0x29, 0xce, 0x48, 0xcc, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x0b, 0x28,
0x45, 0x72, 0x71, 0x06, 0x83, 0x18, 0x1e, 0x89, 0x79, 0x29, 0x42, 0x12, 0x5c, 0xec, 0x8e, 0x29,
0x29, 0x45, 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x0c,
0x17, 0xa7, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0xa7, 0x8b, 0x04, 0x93, 0x02, 0xa3, 0x06,
0x6b, 0x10, 0x42, 0x40, 0x48, 0x84, 0x8b, 0xd5, 0x27, 0x33, 0x3d, 0xa3, 0x44, 0x82, 0x59, 0x81,
0x51, 0x83, 0x23, 0x08, 0xc2, 0x71, 0x92, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6,
0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39,
0x86, 0x24, 0x36, 0xb0, 0x33, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0x1c, 0xa2, 0x06,
0x99, 0x00, 0x00, 0x00,
0x29, 0xce, 0x48, 0xcc, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x52,
0x8a, 0xe4, 0xe2, 0x0c, 0x06, 0x09, 0x79, 0x24, 0xe6, 0xa5, 0x08, 0x49, 0x70, 0xb1, 0x3b, 0xa6,
0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x32,
0x5c, 0x9c, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0x9e, 0x2e, 0x12, 0x4c, 0x0a, 0x8c, 0x1a,
0xac, 0x41, 0x08, 0x01, 0x21, 0x11, 0x2e, 0x56, 0x9f, 0xcc, 0xf4, 0x8c, 0x12, 0x09, 0x66, 0x05,
0x46, 0x0d, 0x8e, 0x20, 0x08, 0xc7, 0x49, 0xe2, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18,
0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5,
0x18, 0x92, 0xd8, 0xc0, 0xf6, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x80, 0x1a, 0x2a, 0xd7,
0x92, 0x00, 0x00, 0x00,
}
func (m *ShakeHand) Marshal() (dAtA []byte, err error) {
......
......@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
syntax = "proto3";
package handshake;
package pb;
message ShakeHand {
string Address = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment