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
423c8bb1
Unverified
Commit
423c8bb1
authored
Feb 23, 2018
by
Guillaume Ballet
Committed by
GitHub
Feb 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16176 from gluk256/255-refactoring
whisper: filters no longer get removed after a while
parents
11473898
6919c364
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
51 deletions
+3
-51
api.go
whisper/whisperv5/api.go
+0
-23
api.go
whisper/whisperv6/api.go
+2
-24
whisper.go
whisper/whisperv6/whisper.go
+1
-4
No files found.
whisper/whisperv5/api.go
View file @
423c8bb1
...
...
@@ -60,32 +60,9 @@ func NewPublicWhisperAPI(w *Whisper) *PublicWhisperAPI {
w
:
w
,
lastUsed
:
make
(
map
[
string
]
time
.
Time
),
}
go
api
.
run
()
return
api
}
// run the api event loop.
// this loop deletes filter that have not been used within filterTimeout
func
(
api
*
PublicWhisperAPI
)
run
()
{
timeout
:=
time
.
NewTicker
(
2
*
time
.
Minute
)
for
{
<-
timeout
.
C
api
.
mu
.
Lock
()
for
id
,
lastUsed
:=
range
api
.
lastUsed
{
if
time
.
Since
(
lastUsed
)
.
Seconds
()
>=
filterTimeout
{
delete
(
api
.
lastUsed
,
id
)
if
err
:=
api
.
w
.
Unsubscribe
(
id
);
err
!=
nil
{
log
.
Error
(
"could not unsubscribe whisper filter"
,
"error"
,
err
)
}
log
.
Debug
(
"delete whisper filter (timeout)"
,
"id"
,
id
)
}
}
api
.
mu
.
Unlock
()
}
}
// Version returns the Whisper sub-protocol version.
func
(
api
*
PublicWhisperAPI
)
Version
(
ctx
context
.
Context
)
string
{
return
ProtocolVersionStr
...
...
whisper/whisperv6/api.go
View file @
423c8bb1
...
...
@@ -61,32 +61,9 @@ func NewPublicWhisperAPI(w *Whisper) *PublicWhisperAPI {
w
:
w
,
lastUsed
:
make
(
map
[
string
]
time
.
Time
),
}
go
api
.
run
()
return
api
}
// run the api event loop.
// this loop deletes filter that have not been used within filterTimeout
func
(
api
*
PublicWhisperAPI
)
run
()
{
timeout
:=
time
.
NewTicker
(
2
*
time
.
Minute
)
for
{
<-
timeout
.
C
api
.
mu
.
Lock
()
for
id
,
lastUsed
:=
range
api
.
lastUsed
{
if
time
.
Since
(
lastUsed
)
.
Seconds
()
>=
filterTimeout
{
delete
(
api
.
lastUsed
,
id
)
if
err
:=
api
.
w
.
Unsubscribe
(
id
);
err
!=
nil
{
log
.
Error
(
"could not unsubscribe whisper filter"
,
"error"
,
err
)
}
log
.
Debug
(
"delete whisper filter (timeout)"
,
"id"
,
id
)
}
}
api
.
mu
.
Unlock
()
}
}
// Version returns the Whisper sub-protocol version.
func
(
api
*
PublicWhisperAPI
)
Version
(
ctx
context
.
Context
)
string
{
return
ProtocolVersionStr
...
...
@@ -219,7 +196,8 @@ func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool {
return
api
.
w
.
DeleteSymKey
(
id
)
}
// MakeLightClient turns the node into light client, which does not forward any incoming messages.
// MakeLightClient turns the node into light client, which does not forward
// any incoming messages, and sends only messages originated in this node.
func
(
api
*
PublicWhisperAPI
)
MakeLightClient
(
ctx
context
.
Context
)
bool
{
api
.
w
.
lightClient
=
true
return
api
.
w
.
lightClient
...
...
whisper/whisperv6/whisper.go
View file @
423c8bb1
...
...
@@ -590,10 +590,7 @@ func (whisper *Whisper) Unsubscribe(id string) error {
// network in the coming cycles.
func
(
whisper
*
Whisper
)
Send
(
envelope
*
Envelope
)
error
{
ok
,
err
:=
whisper
.
add
(
envelope
,
false
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
if
err
==
nil
&&
!
ok
{
return
fmt
.
Errorf
(
"failed to add envelope"
)
}
return
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