Commit 59bff465 authored by Péter Szilágyi's avatar Péter Szilágyi

whisper: general cleanups, documentation

parent 5205b2f1
...@@ -24,7 +24,7 @@ type Envelope struct { ...@@ -24,7 +24,7 @@ type Envelope struct {
Data []byte Data []byte
Nonce uint32 Nonce uint32
hash common.Hash hash common.Hash // Cached hash of the envelope to avoid rehashing every time
} }
// NewEnvelope wraps a Whisper message with expiration and destination data // NewEnvelope wraps a Whisper message with expiration and destination data
...@@ -59,16 +59,6 @@ func (self *Envelope) Seal(pow time.Duration) { ...@@ -59,16 +59,6 @@ func (self *Envelope) Seal(pow time.Duration) {
} }
} }
// valid checks whether the claimed proof of work was indeed executed.
// TODO: Is this really useful? Isn't this always true?
func (self *Envelope) valid() bool {
d := make([]byte, 64)
copy(d[:32], self.rlpWithoutNonce())
binary.BigEndian.PutUint32(d[60:], self.Nonce)
return common.FirstBitSet(common.BigD(crypto.Sha3(d))) > 0
}
// rlpWithoutNonce returns the RLP encoded envelope contents, except the nonce. // rlpWithoutNonce returns the RLP encoded envelope contents, except the nonce.
func (self *Envelope) rlpWithoutNonce() []byte { func (self *Envelope) rlpWithoutNonce() []byte {
enc, _ := rlp.EncodeToBytes([]interface{}{self.Expiry, self.TTL, self.Topics, self.Data}) enc, _ := rlp.EncodeToBytes([]interface{}{self.Expiry, self.TTL, self.Topics, self.Data})
......
// Contains the message filter for fine grained subscriptions.
package whisper package whisper
import "crypto/ecdsa" import "crypto/ecdsa"
// Filter is used to subscribe to specific types of whisper messages.
type Filter struct { type Filter struct {
To *ecdsa.PublicKey To *ecdsa.PublicKey // Recipient of the message
From *ecdsa.PublicKey From *ecdsa.PublicKey // Sender of the message
Topics []Topic Topics []Topic // Topics to watch messages on
Fn func(*Message) Fn func(*Message) // Handler in case of a match
} }
...@@ -9,10 +9,6 @@ import ( ...@@ -9,10 +9,6 @@ import (
"gopkg.in/fatih/set.v0" "gopkg.in/fatih/set.v0"
) )
const (
protocolVersion uint64 = 0x02
)
type peer struct { type peer struct {
host *Whisper host *Whisper
peer *p2p.Peer peer *p2p.Peer
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment