go-waku/waku/v2/protocol/envelope.go
Richard Ramos 3d8aae5b81
Lightpush protocol
- Partially implements #20. Requires some tests
- Extracts wakurelay code to separate file
- Extracts request id gen to separate file
- Initial implementation of lightpush protocol
- Adds utils functions to obtain a message hash
- Publish receives a context to send a message
2021-04-28 16:10:44 -04:00

37 lines
647 B
Go

package protocol
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),
}
}
func (e *Envelope) Message() *pb.WakuMessage {
return e.msg
}
func (e *Envelope) PubsubTopic() string {
return e.pubsubTopic
}
func (e *Envelope) Hash() []byte {
return e.hash
}
func (e *Envelope) Size() int {
return e.size
}