refactor: ToMessage isnt needed

This commit is contained in:
Derrick Hammer 2024-01-08 12:07:19 -05:00
parent 2a0a817006
commit e011d452d5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 1 additions and 7 deletions

View File

@ -9,17 +9,12 @@ var (
//go:generate mockgen -source=encodeable_message.go -destination=../mocks/base/encodeable_message.go -package=base //go:generate mockgen -source=encodeable_message.go -destination=../mocks/base/encodeable_message.go -package=base
type EncodeableMessage interface { type EncodeableMessage interface {
ToMessage() (message []byte, err error)
msgpack.CustomEncoder msgpack.CustomEncoder
} }
type EncodeableMessageImpl struct { type EncodeableMessageImpl struct {
} }
func (e EncodeableMessageImpl) ToMessage() (message []byte, err error) {
return msgpack.Marshal(e)
}
func (e EncodeableMessageImpl) EncodeMsgpack(encoder *msgpack.Encoder) error { func (e EncodeableMessageImpl) EncodeMsgpack(encoder *msgpack.Encoder) error {
panic("this method should be implemented by the child class") panic("this method should be implemented by the child class")
} }

View File

@ -219,8 +219,7 @@ func (p *P2PImpl) OnNewPeer(peer net.Peer, verifyId bool) error {
p.OnNewPeerListen(peer, verifyId) p.OnNewPeerListen(peer, verifyId)
}() }()
handshakeOpenMsg, err := protocol.NewHandshakeOpen(challenge, p.networkID).ToMessage() handshakeOpenMsg, err := msgpack.Marshal(protocol.NewHandshakeOpen(challenge, p.networkID))
if err != nil { if err != nil {
return err return err
} }