whisper: add utility functions for creating topics

This commit is contained in:
Péter Szilágyi
2015-04-14 11:12:09 +03:00
parent cb707ba50c
commit 4af7743663
3 changed files with 58 additions and 8 deletions

View File

@ -30,7 +30,7 @@ type Options struct {
From *ecdsa.PrivateKey
To *ecdsa.PublicKey
TTL time.Duration
Topics [][]byte
Topics []Topic
}
// NewMessage creates and initializes a non-signed, non-encrypted Whisper message.
@ -75,13 +75,8 @@ func (self *Message) Wrap(pow time.Duration, options Options) (*Envelope, error)
return nil, err
}
}
// Convert the user topic into whisper ones
topics := make([]Topic, len(options.Topics))
for i, topic := range options.Topics {
topics[i] = NewTopic(topic)
}
// Wrap the processed message, seal it and return
envelope := NewEnvelope(options.TTL, topics, self)
envelope := NewEnvelope(options.TTL, options.Topics, self)
envelope.Seal(pow)
return envelope, nil