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
ee6531c5
Commit
ee6531c5
authored
Apr 16, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: remove dead code, rename a few constants
parent
6ceb253f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
59 deletions
+7
-59
peer.go
whisper/peer.go
+2
-2
peer_test.go
whisper/peer_test.go
+1
-1
sort.go
whisper/sort.go
+0
-29
sort_test.go
whisper/sort_test.go
+0
-23
whisper.go
whisper/whisper.go
+3
-3
whisper_test.go
whisper/whisper_test.go
+1
-1
No files found.
whisper/peer.go
View file @
ee6531c5
...
...
@@ -88,8 +88,8 @@ func (self *peer) handshake() error {
// and expiration.
func
(
self
*
peer
)
update
()
{
// Start the tickers for the updates
expire
:=
time
.
NewTicker
(
expiration
Ticks
)
transmit
:=
time
.
NewTicker
(
transmission
Ticks
)
expire
:=
time
.
NewTicker
(
expiration
Cycle
)
transmit
:=
time
.
NewTicker
(
transmission
Cycle
)
// Loop and transmit until termination is requested
for
{
...
...
whisper/peer_test.go
View file @
ee6531c5
...
...
@@ -185,7 +185,7 @@ func TestPeerDeliver(t *testing.T) {
t
.
Fatalf
(
"failed to transfer message: %v"
,
err
)
}
select
{
case
<-
time
.
After
(
2
*
transmission
Ticks
)
:
case
<-
time
.
After
(
2
*
transmission
Cycle
)
:
case
<-
arrived
:
t
.
Fatalf
(
"repeating message arrived"
)
}
...
...
whisper/sort.go
deleted
100644 → 0
View file @
6ceb253f
package
whisper
import
(
"sort"
"github.com/ethereum/go-ethereum/common"
)
type
sortedKeys
struct
{
k
[]
int32
}
func
(
self
*
sortedKeys
)
Len
()
int
{
return
len
(
self
.
k
)
}
func
(
self
*
sortedKeys
)
Less
(
i
,
j
int
)
bool
{
return
self
.
k
[
i
]
<
self
.
k
[
j
]
}
func
(
self
*
sortedKeys
)
Swap
(
i
,
j
int
)
{
self
.
k
[
i
],
self
.
k
[
j
]
=
self
.
k
[
j
],
self
.
k
[
i
]
}
func
sortKeys
(
m
map
[
int32
]
common
.
Hash
)
[]
int32
{
sorted
:=
new
(
sortedKeys
)
sorted
.
k
=
make
([]
int32
,
len
(
m
))
i
:=
0
for
key
,
_
:=
range
m
{
sorted
.
k
[
i
]
=
key
i
++
}
sort
.
Sort
(
sorted
)
return
sorted
.
k
}
whisper/sort_test.go
deleted
100644 → 0
View file @
6ceb253f
package
whisper
import
(
"testing"
"github.com/ethereum/go-ethereum/common"
)
func
TestSorting
(
t
*
testing
.
T
)
{
m
:=
map
[
int32
]
common
.
Hash
{
1
:
{
1
},
3
:
{
3
},
2
:
{
2
},
5
:
{
5
},
}
exp
:=
[]
int32
{
1
,
2
,
3
,
5
}
res
:=
sortKeys
(
m
)
for
i
,
k
:=
range
res
{
if
k
!=
exp
[
i
]
{
t
.
Error
(
k
,
"failed. Expected"
,
exp
[
i
])
}
}
}
whisper/whisper.go
View file @
ee6531c5
...
...
@@ -25,8 +25,8 @@ const (
signatureFlag
=
byte
(
1
<<
7
)
signatureLength
=
65
expiration
Ticks
=
800
*
time
.
Millisecond
transmission
Ticks
=
300
*
time
.
Millisecond
expiration
Cycle
=
800
*
time
.
Millisecond
transmission
Cycle
=
300
*
time
.
Millisecond
)
const
(
...
...
@@ -275,7 +275,7 @@ func createFilter(message *Message, topics []Topic) filter.Filter {
// state by expiring stale messages from the pool.
func
(
self
*
Whisper
)
update
()
{
// Start a ticker to check for expirations
expire
:=
time
.
NewTicker
(
expiration
Ticks
)
expire
:=
time
.
NewTicker
(
expiration
Cycle
)
// Repeat updates until termination is requested
for
{
...
...
whisper/whisper_test.go
View file @
ee6531c5
...
...
@@ -178,7 +178,7 @@ func TestMessageExpiration(t *testing.T) {
}
// Wait for expiration and check cache again
time
.
Sleep
(
time
.
Second
)
// wait for expiration
time
.
Sleep
(
expiration
Ticks
)
// wait for cleanup cycle
time
.
Sleep
(
expiration
Cycle
)
// wait for cleanup cycle
if
_
,
ok
:=
node
.
messages
[
envelope
.
Hash
()];
ok
{
t
.
Fatalf
(
"message not expired from cache"
)
}
...
...
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