good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
cb707ba5
Commit
cb707ba5
authored
Apr 13, 2015
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
whisper: push work in progress for bug report
parent
89358d25
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
whisper/whisper.go
+7
-6
7 additions, 6 deletions
whisper/whisper.go
whisper/whisper_test.go
+12
-0
12 additions, 0 deletions
whisper/whisper_test.go
with
19 additions
and
6 deletions
whisper/whisper.go
+
7
−
6
View file @
cb707ba5
...
@@ -25,17 +25,19 @@ const (
...
@@ -25,17 +25,19 @@ const (
signatureLength
=
65
signatureLength
=
65
)
)
const
(
DefaultTimeToLive
=
50
*
time
.
Second
DefaultProofOfWork
=
50
*
time
.
Millisecond
)
type
MessageEvent
struct
{
type
MessageEvent
struct
{
To
*
ecdsa
.
PrivateKey
To
*
ecdsa
.
PrivateKey
From
*
ecdsa
.
PublicKey
From
*
ecdsa
.
PublicKey
Message
*
Message
Message
*
Message
}
}
const
(
// Whisper represents a dark communication interface through the Ethereum
DefaultTimeToLive
=
50
*
time
.
Second
// network, using its very own P2P communication layer.
DefaultProofOfWork
=
50
*
time
.
Millisecond
)
type
Whisper
struct
{
type
Whisper
struct
{
protocol
p2p
.
Protocol
protocol
p2p
.
Protocol
filters
*
filter
.
Filters
filters
*
filter
.
Filters
...
@@ -199,7 +201,6 @@ func (self *Whisper) add(envelope *Envelope) error {
...
@@ -199,7 +201,6 @@ func (self *Whisper) add(envelope *Envelope) error {
self
.
expiry
[
envelope
.
Expiry
]
.
Add
(
hash
)
self
.
expiry
[
envelope
.
Expiry
]
.
Add
(
hash
)
go
self
.
postEvent
(
envelope
)
go
self
.
postEvent
(
envelope
)
}
}
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"added whisper envelope %x
\n
"
,
envelope
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"added whisper envelope %x
\n
"
,
envelope
)
return
nil
return
nil
...
...
This diff is collapsed.
Click to expand it.
whisper/whisper_test.go
+
12
−
0
View file @
cb707ba5
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/nat"
)
)
...
@@ -17,6 +18,7 @@ type testNode struct {
...
@@ -17,6 +18,7 @@ type testNode struct {
}
}
func
startNodes
(
n
int
)
([]
*
testNode
,
error
)
{
func
startNodes
(
n
int
)
([]
*
testNode
,
error
)
{
// Start up the cluster of nodes
cluster
:=
make
([]
*
testNode
,
0
,
n
)
cluster
:=
make
([]
*
testNode
,
0
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
i
:=
0
;
i
<
n
;
i
++
{
shh
:=
New
()
shh
:=
New
()
...
@@ -46,6 +48,11 @@ func startNodes(n int) ([]*testNode, error) {
...
@@ -46,6 +48,11 @@ func startNodes(n int) ([]*testNode, error) {
client
:
shh
,
client
:
shh
,
})
})
}
}
// Manually wire together the cluster nodes
root
:=
cluster
[
0
]
.
server
.
Self
()
for
_
,
node
:=
range
cluster
[
1
:
]
{
node
.
server
.
SuggestPeer
(
root
)
}
return
cluster
,
nil
return
cluster
,
nil
}
}
...
@@ -56,6 +63,7 @@ func stopNodes(cluster []*testNode) {
...
@@ -56,6 +63,7 @@ func stopNodes(cluster []*testNode) {
}
}
func
TestSelfMessage
(
t
*
testing
.
T
)
{
func
TestSelfMessage
(
t
*
testing
.
T
)
{
// Start the single node cluster
cluster
,
err
:=
startNodes
(
1
)
cluster
,
err
:=
startNodes
(
1
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to boot test cluster: %v"
,
err
)
t
.
Fatalf
(
"failed to boot test cluster: %v"
,
err
)
...
@@ -96,6 +104,10 @@ func TestSelfMessage(t *testing.T) {
...
@@ -96,6 +104,10 @@ func TestSelfMessage(t *testing.T) {
}
}
func
TestDirectMessage
(
t
*
testing
.
T
)
{
func
TestDirectMessage
(
t
*
testing
.
T
)
{
glog
.
SetV
(
6
)
glog
.
SetToStderr
(
true
)
// Start the sender-recipient cluster
cluster
,
err
:=
startNodes
(
2
)
cluster
,
err
:=
startNodes
(
2
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to boot test cluster: %v"
,
err
)
t
.
Fatalf
(
"failed to boot test cluster: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment