Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
remove autonat pb for protobuf implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kant committed Oct 12, 2023
1 parent 60cc84d commit d9b82b6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/p2p/protobuf/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package protobuf
import (
"context"
"fmt"

"github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
"github.com/primevprotocol/mev-commit/pkg/p2p"
"google.golang.org/protobuf/proto"
)

type Encoder interface {
ReadMsg(context.Context, *pb.Message) error
WriteMsg(context.Context, *pb.Message) error
ReadMsg(context.Context, proto.Message) error
WriteMsg(context.Context, proto.Message) error
}

type protobuf struct {
Expand All @@ -22,7 +20,7 @@ func NewReaderWriter(s p2p.Stream) Encoder {
return &protobuf{s}
}

func (p *protobuf) ReadMsg(ctx context.Context, msg *pb.Message) error {
func (p *protobuf) ReadMsg(ctx context.Context, msg proto.Message) error {
type result struct {
msgBuf []byte
err error
Expand Down Expand Up @@ -50,7 +48,7 @@ func (p *protobuf) ReadMsg(ctx context.Context, msg *pb.Message) error {
}
}

func (p *protobuf) WriteMsg(ctx context.Context, msg *pb.Message) error {
func (p *protobuf) WriteMsg(ctx context.Context, msg proto.Message) error {
msgBuf, err := proto.Marshal(msg)
if err != nil {
return fmt.Errorf("failed marshaling message: %w", err)
Expand Down

0 comments on commit d9b82b6

Please sign in to comment.