go-waku/waku/v2/protocol/envelope.go

37 lines
647 B
Go
Raw Normal View History

2021-04-22 00:09:37 +00:00
package protocol
2021-04-22 00:09:37 +00:00
import "github.com/status-im/go-waku/waku/v2/protocol/pb"
type Envelope struct {
msg *pb.WakuMessage
pubsubTopic string
size int
hash []byte
}
func NewEnvelope(msg *pb.WakuMessage, pubSubTopic string) *Envelope {
data, _ := msg.Marshal()
return &Envelope{
msg: msg,
pubsubTopic: pubSubTopic,
size: len(data),
hash: pb.Hash(data),
}
}
2021-04-22 00:09:37 +00:00
func (e *Envelope) Message() *pb.WakuMessage {
return e.msg
}
func (e *Envelope) PubsubTopic() string {
return e.pubsubTopic
}
2021-04-11 23:43:59 +00:00
func (e *Envelope) Hash() []byte {
return e.hash
}
func (e *Envelope) Size() int {
return e.size
}