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
7bd2fbe2
Commit
7bd2fbe2
authored
Feb 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed whisper "to" filtering. Closes #283
parent
623469cb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
whisper.html
cmd/mist/assets/examples/whisper.html
+10
-0
message.go
whisper/message.go
+2
-2
whisper.go
whisper/whisper.go
+1
-1
whisper.go
xeth/whisper.go
+3
-1
No files found.
cmd/mist/assets/examples/whisper.html
View file @
7bd2fbe2
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<h1>
Whisper test
</h1>
<h1>
Whisper test
</h1>
<button
onclick=
"test()"
>
Send
</button>
<button
onclick=
"test()"
>
Send
</button>
<button
onclick=
"test2()"
>
Private send
</button>
<table
width=
"100%"
id=
"table"
>
<table
width=
"100%"
id=
"table"
>
<tr>
<tr>
...
@@ -44,10 +45,19 @@
...
@@ -44,10 +45,19 @@
document
.
querySelector
(
"#table"
).
innerHTML
+=
"<tr><td colspan='2'>"
+
JSON
.
stringify
(
message
)
+
"</td></tr>"
;
document
.
querySelector
(
"#table"
).
innerHTML
+=
"<tr><td colspan='2'>"
+
JSON
.
stringify
(
message
)
+
"</td></tr>"
;
});
});
var
selfWatch
=
shh
.
watch
({
to
:
id
,
topics
:
[
"test"
]})
selfWatch
.
arrived
(
function
(
message
)
{
document
.
querySelector
(
"#table"
).
innerHTML
+=
"<tr><td>To me</td><td>"
+
JSON
.
stringify
(
message
)
+
"</td></tr>"
;
});
function
test
()
{
function
test
()
{
shh
.
post
({
topics
:
[
"test"
],
payload
:
web3
.
fromAscii
(
"test it"
)});
shh
.
post
({
topics
:
[
"test"
],
payload
:
web3
.
fromAscii
(
"test it"
)});
count
();
count
();
}
function
test2
()
{
shh
.
post
({
to
:
id
,
topics
:
[
"test"
],
payload
:
web3
.
fromAscii
(
"Private"
)});
count
();
}
}
function
count
()
{
function
count
()
{
...
...
whisper/message.go
View file @
7bd2fbe2
...
@@ -11,11 +11,11 @@ type Message struct {
...
@@ -11,11 +11,11 @@ type Message struct {
Flags
byte
Flags
byte
Signature
[]
byte
Signature
[]
byte
Payload
[]
byte
Payload
[]
byte
Sent
u
int64
Sent
int64
}
}
func
NewMessage
(
payload
[]
byte
)
*
Message
{
func
NewMessage
(
payload
[]
byte
)
*
Message
{
return
&
Message
{
Flags
:
0
,
Payload
:
payload
}
return
&
Message
{
Flags
:
0
,
Payload
:
payload
,
Sent
:
time
.
Now
()
.
Unix
()
}
}
}
func
(
self
*
Message
)
hash
()
[]
byte
{
func
(
self
*
Message
)
hash
()
[]
byte
{
...
...
whisper/whisper.go
View file @
7bd2fbe2
...
@@ -269,7 +269,7 @@ func (self *Whisper) Protocol() p2p.Protocol {
...
@@ -269,7 +269,7 @@ func (self *Whisper) Protocol() p2p.Protocol {
func
createFilter
(
message
*
Message
,
topics
[][]
byte
,
key
*
ecdsa
.
PrivateKey
)
filter
.
Filter
{
func
createFilter
(
message
*
Message
,
topics
[][]
byte
,
key
*
ecdsa
.
PrivateKey
)
filter
.
Filter
{
return
filter
.
Generic
{
return
filter
.
Generic
{
Str1
:
string
(
crypto
.
FromECDSA
(
k
ey
)),
Str2
:
string
(
crypto
.
FromECDSAPub
(
message
.
Recover
())),
Str1
:
string
(
crypto
.
FromECDSA
Pub
(
&
key
.
PublicK
ey
)),
Str2
:
string
(
crypto
.
FromECDSAPub
(
message
.
Recover
())),
Data
:
bytesToMap
(
topics
),
Data
:
bytesToMap
(
topics
),
}
}
}
}
xeth/whisper.go
View file @
7bd2fbe2
...
@@ -2,6 +2,7 @@ package xeth
...
@@ -2,6 +2,7 @@ package xeth
import
(
import
(
"errors"
"errors"
"fmt"
"time"
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
...
@@ -31,6 +32,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
...
@@ -31,6 +32,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
pk
:=
crypto
.
ToECDSAPub
(
fromHex
(
from
))
pk
:=
crypto
.
ToECDSAPub
(
fromHex
(
from
))
if
key
:=
self
.
Whisper
.
GetIdentity
(
pk
);
key
!=
nil
||
len
(
from
)
==
0
{
if
key
:=
self
.
Whisper
.
GetIdentity
(
pk
);
key
!=
nil
||
len
(
from
)
==
0
{
fmt
.
Println
(
"POST:"
,
to
)
msg
:=
whisper
.
NewMessage
(
fromHex
(
payload
))
msg
:=
whisper
.
NewMessage
(
fromHex
(
payload
))
envelope
,
err
:=
msg
.
Seal
(
time
.
Duration
(
priority
*
100000
),
whisper
.
Opts
{
envelope
,
err
:=
msg
.
Seal
(
time
.
Duration
(
priority
*
100000
),
whisper
.
Opts
{
Ttl
:
time
.
Duration
(
ttl
)
*
time
.
Second
,
Ttl
:
time
.
Duration
(
ttl
)
*
time
.
Second
,
...
@@ -101,7 +103,7 @@ type WhisperMessage struct {
...
@@ -101,7 +103,7 @@ type WhisperMessage struct {
ref
*
whisper
.
Message
ref
*
whisper
.
Message
Payload
string
`json:"payload"`
Payload
string
`json:"payload"`
From
string
`json:"from"`
From
string
`json:"from"`
Sent
uint64
`json:"time"`
Sent
int64
`json:"time"`
}
}
func
NewWhisperMessage
(
msg
*
whisper
.
Message
)
WhisperMessage
{
func
NewWhisperMessage
(
msg
*
whisper
.
Message
)
WhisperMessage
{
...
...
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