aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/envelope.go
diff options
context:
space:
mode:
authorGuillaume Ballet <gballet@gmail.com>2017-12-08 23:08:56 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-12-08 23:08:56 +0800
commitbf62acf0332c962916787a23c78a2513137625ea (patch)
treeab615efc3a777eaa9463bb549395399aa619ccc2 /whisper/whisperv6/envelope.go
parent586198cceaf51435121b7e1166adf21910fee51a (diff)
downloaddexon-bf62acf0332c962916787a23c78a2513137625ea.tar
dexon-bf62acf0332c962916787a23c78a2513137625ea.tar.gz
dexon-bf62acf0332c962916787a23c78a2513137625ea.tar.bz2
dexon-bf62acf0332c962916787a23c78a2513137625ea.tar.lz
dexon-bf62acf0332c962916787a23c78a2513137625ea.tar.xz
dexon-bf62acf0332c962916787a23c78a2513137625ea.tar.zst
dexon-bf62acf0332c962916787a23c78a2513137625ea.zip
whisper/whisperv6: remove Version from the envelope (#15621)
Diffstat (limited to 'whisper/whisperv6/envelope.go')
-rw-r--r--whisper/whisperv6/envelope.go37
1 files changed, 12 insertions, 25 deletions
diff --git a/whisper/whisperv6/envelope.go b/whisper/whisperv6/envelope.go
index c8b56ff36..676df669b 100644
--- a/whisper/whisperv6/envelope.go
+++ b/whisper/whisperv6/envelope.go
@@ -36,12 +36,11 @@ import (
// Envelope represents a clear-text data packet to transmit through the Whisper
// network. Its contents may or may not be encrypted and signed.
type Envelope struct {
- Version []byte
- Expiry uint32
- TTL uint32
- Topic TopicType
- Data []byte
- Nonce uint64
+ Expiry uint32
+ TTL uint32
+ Topic TopicType
+ Data []byte
+ Nonce uint64
pow float64 // Message-specific PoW as described in the Whisper specification.
hash common.Hash // Cached hash of the envelope to avoid rehashing every time.
@@ -50,12 +49,12 @@ type Envelope struct {
// size returns the size of envelope as it is sent (i.e. public fields only)
func (e *Envelope) size() int {
- return EnvelopeHeaderLength + len(e.Version) + len(e.Data)
+ return EnvelopeHeaderLength + len(e.Data)
}
// rlpWithoutNonce returns the RLP encoded envelope contents, except the nonce.
func (e *Envelope) rlpWithoutNonce() []byte {
- res, _ := rlp.EncodeToBytes([]interface{}{e.Version, e.Expiry, e.TTL, e.Topic, e.Data})
+ res, _ := rlp.EncodeToBytes([]interface{}{e.Expiry, e.TTL, e.Topic, e.Data})
return res
}
@@ -63,27 +62,16 @@ func (e *Envelope) rlpWithoutNonce() []byte {
// included into an envelope for network forwarding.
func NewEnvelope(ttl uint32, topic TopicType, msg *sentMessage) *Envelope {
env := Envelope{
- Version: make([]byte, 1),
- Expiry: uint32(time.Now().Add(time.Second * time.Duration(ttl)).Unix()),
- TTL: ttl,
- Topic: topic,
- Data: msg.Raw,
- Nonce: 0,
- }
-
- if EnvelopeVersion < 256 {
- env.Version[0] = byte(EnvelopeVersion)
- } else {
- panic("please increase the size of Envelope.Version before releasing this version")
+ Expiry: uint32(time.Now().Add(time.Second * time.Duration(ttl)).Unix()),
+ TTL: ttl,
+ Topic: topic,
+ Data: msg.Raw,
+ Nonce: 0,
}
return &env
}
-func (e *Envelope) Ver() uint64 {
- return bytesToUintLittleEndian(e.Version)
-}
-
// Seal closes the envelope by spending the requested amount of time as a proof
// of work on hashing the data.
func (e *Envelope) Seal(options *MessageParams) error {
@@ -236,7 +224,6 @@ func (e *Envelope) Open(watcher *Filter) (msg *ReceivedMessage) {
msg.TTL = e.TTL
msg.Sent = e.Expiry - e.TTL
msg.EnvelopeHash = e.Hash()
- msg.EnvelopeVersion = e.Ver()
}
return msg
}