github.com/status-im/status-go@v1.1.0/eth-node/bridge/geth/envelope.go (about) 1 package gethbridge 2 3 import ( 4 "io" 5 6 "github.com/ethereum/go-ethereum/rlp" 7 "github.com/status-im/status-go/eth-node/types" 8 waku "github.com/status-im/status-go/waku/common" 9 ) 10 11 type wakuEnvelope struct { 12 env *waku.Envelope 13 } 14 15 // NewWakuEnvelope returns an object that wraps Geth's Waku Envelope in a types interface. 16 func NewWakuEnvelope(e *waku.Envelope) types.Envelope { 17 return &wakuEnvelope{env: e} 18 } 19 20 func (w *wakuEnvelope) Unwrap() interface{} { 21 return w.env 22 } 23 24 func (w *wakuEnvelope) Hash() types.Hash { 25 return types.Hash(w.env.Hash()) 26 } 27 28 func (w *wakuEnvelope) Bloom() []byte { 29 return w.env.Bloom() 30 } 31 32 func (w *wakuEnvelope) PoW() float64 { 33 return w.env.PoW() 34 } 35 36 func (w *wakuEnvelope) Expiry() uint32 { 37 return w.env.Expiry 38 } 39 40 func (w *wakuEnvelope) TTL() uint32 { 41 return w.env.TTL 42 } 43 44 func (w *wakuEnvelope) Topic() types.TopicType { 45 return types.TopicType(w.env.Topic) 46 } 47 48 func (w *wakuEnvelope) Size() int { 49 return len(w.env.Data) 50 } 51 52 func (w *wakuEnvelope) DecodeRLP(s *rlp.Stream) error { 53 return w.env.DecodeRLP(s) 54 } 55 56 func (w *wakuEnvelope) EncodeRLP(writer io.Writer) error { 57 return rlp.Encode(writer, w.env) 58 }