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
d7b4b40c
Commit
d7b4b40c
authored
Feb 23, 2018
by
Vlad
Browse files
Options
Downloads
Patches
Plain Diff
whisper: light client mode introduced
parent
a1984ce7
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/whisperv6/api.go
+12
-0
12 additions, 0 deletions
whisper/whisperv6/api.go
whisper/whisperv6/whisper.go
+7
-4
7 additions, 4 deletions
whisper/whisperv6/whisper.go
with
19 additions
and
4 deletions
whisper/whisperv6/api.go
+
12
−
0
View file @
d7b4b40c
...
...
@@ -219,6 +219,18 @@ 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.
func
(
api
*
PublicWhisperAPI
)
MakeLightClient
(
ctx
context
.
Context
)
bool
{
api
.
w
.
lightClient
=
true
return
api
.
w
.
lightClient
}
// CancelLightClient cancels light client mode.
func
(
api
*
PublicWhisperAPI
)
CancelLightClient
(
ctx
context
.
Context
)
bool
{
api
.
w
.
lightClient
=
false
return
!
api
.
w
.
lightClient
}
//go:generate gencodec -type NewMessage -field-override newMessageOverride -out gen_newmessage_json.go
// NewMessage represents a new whisper message that is posted through the RPC.
...
...
This diff is collapsed.
Click to expand it.
whisper/whisperv6/whisper.go
+
7
−
4
View file @
d7b4b40c
...
...
@@ -82,6 +82,8 @@ type Whisper struct {
syncAllowance
int
// maximum time in seconds allowed to process the whisper-related messages
lightClient
bool
// indicates is this node is pure light client (does not forward any messages)
statsMu
sync
.
Mutex
// guard stats
stats
Statistics
// Statistics of whisper node
...
...
@@ -587,7 +589,7 @@ func (whisper *Whisper) Unsubscribe(id string) error {
// Send injects a message into the whisper send queue, to be distributed in the
// network in the coming cycles.
func
(
whisper
*
Whisper
)
Send
(
envelope
*
Envelope
)
error
{
ok
,
err
:=
whisper
.
add
(
envelope
)
ok
,
err
:=
whisper
.
add
(
envelope
,
false
)
if
err
!=
nil
{
return
err
}
...
...
@@ -673,7 +675,7 @@ func (whisper *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
trouble
:=
false
for
_
,
env
:=
range
envelopes
{
cached
,
err
:=
whisper
.
add
(
env
)
cached
,
err
:=
whisper
.
add
(
env
,
whisper
.
lightClient
)
if
err
!=
nil
{
trouble
=
true
log
.
Error
(
"bad envelope received, peer will be disconnected"
,
"peer"
,
p
.
peer
.
ID
(),
"err"
,
err
)
...
...
@@ -746,7 +748,8 @@ func (whisper *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
// add inserts a new envelope into the message pool to be distributed within the
// whisper network. It also inserts the envelope into the expiration pool at the
// appropriate time-stamp. In case of error, connection should be dropped.
func
(
whisper
*
Whisper
)
add
(
envelope
*
Envelope
)
(
bool
,
error
)
{
// param isP2P indicates whether the message is peer-to-peer (should not be forwarded).
func
(
whisper
*
Whisper
)
add
(
envelope
*
Envelope
,
isP2P
bool
)
(
bool
,
error
)
{
now
:=
uint32
(
time
.
Now
()
.
Unix
())
sent
:=
envelope
.
Expiry
-
envelope
.
TTL
...
...
@@ -811,7 +814,7 @@ func (whisper *Whisper) add(envelope *Envelope) (bool, error) {
whisper
.
statsMu
.
Lock
()
whisper
.
stats
.
memoryUsed
+=
envelope
.
size
()
whisper
.
statsMu
.
Unlock
()
whisper
.
postEvent
(
envelope
,
false
)
// notify the local node about the new message
whisper
.
postEvent
(
envelope
,
isP2P
)
// notify the local node about the new message
if
whisper
.
mailServer
!=
nil
{
whisper
.
mailServer
.
Archive
(
envelope
)
}
...
...
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