From 27db33dbda4fab64369bfbb8b13c8a60838732d4 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Thu, 20 Oct 2022 16:50:57 -0400 Subject: [PATCH] split wrap into wrap / unwrap types --- p2p/peer.go | 2 +- p2p/types.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/p2p/peer.go b/p2p/peer.go index 8a49668ef..ba5d42d32 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -420,7 +420,7 @@ func createMConnection( "peer_id", string(p.ID()), "chID", fmt.Sprintf("%#x", chID), } - if w, ok := msg.(Wrapper); ok { + if w, ok := msg.(Unwrapper); ok { msg, err = w.Unwrap() if err != nil { // TODO(williambanfield) add error log line. diff --git a/p2p/types.go b/p2p/types.go index bab051639..e8182a6f3 100644 --- a/p2p/types.go +++ b/p2p/types.go @@ -19,12 +19,14 @@ type Envelope struct { // (e.g. via oneof fields). If a Channel's message type implements Wrapper, the // Router will automatically wrap outbound messages and unwrap inbound messages, // such that reactors do not have to do this themselves. -type Wrapper interface { +type Unwrapper interface { proto.Message - // Wrap will take a message and wrap it in this one if possible. - Wrap(proto.Message) error - // Unwrap will unwrap the inner message contained in this message. Unwrap() (proto.Message, error) } + +type Wrapper interface { + // Wrap will take the underlying message and wrap it in its wrapper type. + Wrap() (proto.Message, error) +}