Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
59bff465
Commit
59bff465
authored
Apr 14, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: general cleanups, documentation
parent
5205b2f1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
129 deletions
+146
-129
envelope.go
whisper/envelope.go
+1
-11
filter.go
whisper/filter.go
+7
-4
peer.go
whisper/peer.go
+0
-4
whisper.go
whisper/whisper.go
+138
-110
No files found.
whisper/envelope.go
View file @
59bff465
...
...
@@ -24,7 +24,7 @@ type Envelope struct {
Data
[]
byte
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
...
...
@@ -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.
func
(
self
*
Envelope
)
rlpWithoutNonce
()
[]
byte
{
enc
,
_
:=
rlp
.
EncodeToBytes
([]
interface
{}{
self
.
Expiry
,
self
.
TTL
,
self
.
Topics
,
self
.
Data
})
...
...
whisper/filter.go
View file @
59bff465
// Contains the message filter for fine grained subscriptions.
package
whisper
import
"crypto/ecdsa"
// Filter is used to subscribe to specific types of whisper messages.
type
Filter
struct
{
To
*
ecdsa
.
PublicKey
From
*
ecdsa
.
PublicKey
Topics
[]
Topic
Fn
func
(
*
Message
)
To
*
ecdsa
.
PublicKey
// Recipient of the message
From
*
ecdsa
.
PublicKey
// Sender of the message
Topics
[]
Topic
// Topics to watch messages on
Fn
func
(
*
Message
)
// Handler in case of a match
}
whisper/peer.go
View file @
59bff465
...
...
@@ -9,10 +9,6 @@ import (
"gopkg.in/fatih/set.v0"
)
const
(
protocolVersion
uint64
=
0x02
)
type
peer
struct
{
host
*
Whisper
peer
*
p2p
.
Peer
...
...
whisper/whisper.go
View file @
59bff465
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment