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
f6efdd8a
Commit
f6efdd8a
authored
Apr 14, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: shorten constants to TTL and PoW
parent
1a4cfc17
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
15 deletions
+15
-15
main.go
whisper/main.go
+2
-2
message.go
whisper/message.go
+1
-1
message_test.go
whisper/message_test.go
+4
-4
whisper.go
whisper/whisper.go
+2
-2
whisper_test.go
whisper/whisper_test.go
+6
-6
No files found.
whisper/main.go
View file @
f6efdd8a
...
...
@@ -69,10 +69,10 @@ func selfSend(shh *whisper.Whisper, payload []byte) error {
})
// Wrap the payload and encrypt it
msg
:=
whisper
.
NewMessage
(
payload
)
envelope
,
err
:=
msg
.
Wrap
(
whisper
.
DefaultP
roofOfWork
,
whisper
.
Options
{
envelope
,
err
:=
msg
.
Wrap
(
whisper
.
DefaultP
oW
,
whisper
.
Options
{
From
:
id
,
To
:
&
id
.
PublicKey
,
TTL
:
whisper
.
DefaultT
imeToLive
,
TTL
:
whisper
.
DefaultT
TL
,
})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to seal message: %v"
,
err
)
...
...
whisper/message.go
View file @
f6efdd8a
...
...
@@ -62,7 +62,7 @@ func NewMessage(payload []byte) *Message {
func
(
self
*
Message
)
Wrap
(
pow
time
.
Duration
,
options
Options
)
(
*
Envelope
,
error
)
{
// Use the default TTL if non was specified
if
options
.
TTL
==
0
{
options
.
TTL
=
DefaultT
imeToLive
options
.
TTL
=
DefaultT
TL
}
// Sign and encrypt the message if requested
if
options
.
From
!=
nil
{
...
...
whisper/message_test.go
View file @
f6efdd8a
...
...
@@ -13,7 +13,7 @@ func TestMessageSimpleWrap(t *testing.T) {
payload
:=
[]
byte
(
"hello world"
)
msg
:=
NewMessage
(
payload
)
if
_
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{});
err
!=
nil
{
if
_
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{});
err
!=
nil
{
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
}
if
msg
.
Flags
&
signatureFlag
!=
0
{
...
...
@@ -36,7 +36,7 @@ func TestMessageCleartextSignRecover(t *testing.T) {
payload
:=
[]
byte
(
"hello world"
)
msg
:=
NewMessage
(
payload
)
if
_
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
if
_
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
From
:
key
,
});
err
!=
nil
{
t
.
Fatalf
(
"failed to sign message: %v"
,
err
)
...
...
@@ -69,7 +69,7 @@ func TestMessageAnonymousEncryptDecrypt(t *testing.T) {
payload
:=
[]
byte
(
"hello world"
)
msg
:=
NewMessage
(
payload
)
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
To
:
&
key
.
PublicKey
,
})
if
err
!=
nil
{
...
...
@@ -104,7 +104,7 @@ func TestMessageFullCrypto(t *testing.T) {
payload
:=
[]
byte
(
"hello world"
)
msg
:=
NewMessage
(
payload
)
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
From
:
fromKey
,
To
:
&
toKey
.
PublicKey
,
})
...
...
whisper/whisper.go
View file @
f6efdd8a
...
...
@@ -30,8 +30,8 @@ const (
)
const
(
DefaultT
imeToLive
=
50
*
time
.
Second
DefaultP
roofOfWork
=
50
*
time
.
Millisecond
DefaultT
TL
=
50
*
time
.
Second
DefaultP
oW
=
50
*
time
.
Millisecond
)
type
MessageEvent
struct
{
...
...
whisper/whisper_test.go
View file @
f6efdd8a
...
...
@@ -83,10 +83,10 @@ func TestSelfMessage(t *testing.T) {
})
// Send a dummy message to oneself
msg
:=
NewMessage
([]
byte
(
"self whisper"
))
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
From
:
self
,
To
:
&
self
.
PublicKey
,
TTL
:
DefaultT
imeToLive
,
TTL
:
DefaultT
TL
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
...
...
@@ -126,10 +126,10 @@ func TestDirectMessage(t *testing.T) {
})
// Send a dummy message from the sender
msg
:=
NewMessage
([]
byte
(
"direct whisper"
))
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
From
:
senderId
,
To
:
&
recipientId
.
PublicKey
,
TTL
:
DefaultT
imeToLive
,
TTL
:
DefaultT
TL
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
...
...
@@ -184,9 +184,9 @@ func testBroadcast(anonymous bool, t *testing.T) {
}
// Send a dummy message from the sender
msg
:=
NewMessage
([]
byte
(
"broadcast whisper"
))
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
roofOfWork
,
Options
{
envelope
,
err
:=
msg
.
Wrap
(
DefaultP
oW
,
Options
{
Topics
:
NewTopicsFromStrings
(
"broadcast topic"
),
TTL
:
DefaultT
imeToLive
,
TTL
:
DefaultT
TL
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
...
...
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