Added encryption for messages better API for sealing messages

This commit is contained in:
obscuren
2014-12-10 00:03:50 +01:00
parent 87adff7e18
commit 984c7e6689
4 changed files with 90 additions and 23 deletions

View File

@@ -16,8 +16,8 @@ const (
)
type Envelope struct {
Expiry int32 // Whisper protocol specifies int32, really should be int64
Ttl int32 // ^^^^^^
Expiry uint32 // Whisper protocol specifies int32, really should be int64
Ttl uint32 // ^^^^^^
Topics [][]byte
Data []byte
Nonce uint32
@@ -52,11 +52,11 @@ func (self *Envelope) Hash() Hash {
func NewEnvelope(ttl time.Duration, topics [][]byte, data *Message) *Envelope {
exp := time.Now().Add(ttl)
return &Envelope{int32(exp.Unix()), int32(ttl.Seconds()), topics, data.Bytes(), 0, Hash{}}
return &Envelope{uint32(exp.Unix()), uint32(ttl.Seconds()), topics, data.Bytes(), 0, Hash{}}
}
func (self *Envelope) Seal() {
self.proveWork(DefaultPow)
func (self *Envelope) Seal(pow time.Duration) {
self.proveWork(pow)
}
func (self *Envelope) proveWork(dura time.Duration) {