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
70ded4cb
Commit
70ded4cb
authored
Apr 22, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xeth: fix un-decoded whisper RPC topic string bug
parent
e252dae4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
whisper.go
xeth/whisper.go
+16
-2
No files found.
xeth/whisper.go
View file @
70ded4cb
...
...
@@ -39,12 +39,17 @@ func (self *Whisper) HasIdentity(key string) bool {
// Post injects a message into the whisper network for distribution.
func
(
self
*
Whisper
)
Post
(
payload
string
,
to
,
from
string
,
topics
[]
string
,
priority
,
ttl
uint32
)
error
{
// Decode the topic strings
topicsDecoded
:=
make
([][]
byte
,
len
(
topics
))
for
i
,
topic
:=
range
topics
{
topicsDecoded
[
i
]
=
common
.
FromHex
(
topic
)
}
// Construct the whisper message and transmission options
message
:=
whisper
.
NewMessage
(
common
.
FromHex
(
payload
))
options
:=
whisper
.
Options
{
To
:
crypto
.
ToECDSAPub
(
common
.
FromHex
(
to
)),
TTL
:
time
.
Duration
(
ttl
)
*
time
.
Second
,
Topics
:
whisper
.
NewTopics
FromStrings
(
topics
...
),
Topics
:
whisper
.
NewTopics
(
topicsDecoded
...
),
}
if
len
(
from
)
!=
0
{
if
key
:=
self
.
Whisper
.
GetIdentity
(
crypto
.
ToECDSAPub
(
common
.
FromHex
(
from
)));
key
!=
nil
{
...
...
@@ -68,10 +73,19 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
// Watch installs a new message handler to run in case a matching packet arrives
// from the whisper network.
func
(
self
*
Whisper
)
Watch
(
to
,
from
string
,
topics
[][]
string
,
fn
func
(
WhisperMessage
))
int
{
// Decode the topic strings
topicsDecoded
:=
make
([][][]
byte
,
len
(
topics
))
for
i
,
condition
:=
range
topics
{
topicsDecoded
[
i
]
=
make
([][]
byte
,
len
(
condition
))
for
j
,
topic
:=
range
condition
{
topicsDecoded
[
i
][
j
]
=
common
.
FromHex
(
topic
)
}
}
// Assemble and inject the filter into the whisper client
filter
:=
whisper
.
Filter
{
To
:
crypto
.
ToECDSAPub
(
common
.
FromHex
(
to
)),
From
:
crypto
.
ToECDSAPub
(
common
.
FromHex
(
from
)),
Topics
:
whisper
.
NewFilterTopics
FromStrings
(
topics
...
),
Topics
:
whisper
.
NewFilterTopics
(
topicsDecoded
...
),
}
filter
.
Fn
=
func
(
message
*
whisper
.
Message
)
{
fn
(
NewWhisperMessage
(
message
))
...
...
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