-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract message constructor out of the Message interface
- Loading branch information
Showing
5 changed files
with
57 additions
and
46 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
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 @@ | ||
package msngr | ||
|
||
import "github.com/libp2p/go-libp2p/core/peer" | ||
|
||
// MessageBase is a helper to struct that users may embed into their custom Message implementations. | ||
// It's sole purpose is to minimize boilerplate code. | ||
type MessageBase struct { | ||
FromPeer, ToPeer peer.ID | ||
} | ||
|
||
func (mb *MessageBase) From() peer.ID { | ||
return mb.FromPeer | ||
} | ||
|
||
func (mb *MessageBase) To() peer.ID { | ||
return mb.ToPeer | ||
} |
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