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
af927ffd
Commit
af927ffd
authored
Jan 30, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added whisper messages
* have identity & get messages
parent
c03d4034
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
5 deletions
+59
-5
whisper.html
cmd/mist/assets/examples/whisper.html
+20
-2
message.go
rpc/message.go
+15
-1
packages.go
rpc/packages.go
+24
-2
No files found.
cmd/mist/assets/examples/whisper.html
View file @
af927ffd
...
...
@@ -12,10 +12,20 @@
<button
onclick=
"test()"
>
Send
</button>
<table
width=
"100%"
id=
"table"
>
<tr>
<td>
Count
</td>
<td
id=
"count"
></td>
</tr>
<tr>
<td>
ID
</td>
<td
id=
"id"
></td>
</tr>
<tr>
<td>
Has identity
</td>
<td
id=
"known"
></td>
</tr>
</table>
</body>
...
...
@@ -27,13 +37,21 @@
var
id
=
shh
.
newIdentity
();
document
.
querySelector
(
"#id"
).
innerHTML
=
id
;
document
.
querySelector
(
"#known"
).
innerHTML
=
shh
.
haveIdentity
(
id
);
shh
.
watch
({
topics
:
[
"test"
]}).
arrived
(
function
(
message
)
{
var
watch
=
shh
.
watch
({
topics
:
[
"test"
]})
watch
.
arrived
(
function
(
message
)
{
document
.
querySelector
(
"#table"
).
innerHTML
+=
"<tr><td colspan='2'>"
+
JSON
.
stringify
(
message
)
+
"</td></tr>"
;
});
function
test
()
{
shh
.
post
({
topics
:
[
"test"
],
payload
:
web3
.
fromAscii
(
"test it"
)})
shh
.
post
({
topics
:
[
"test"
],
payload
:
web3
.
fromAscii
(
"test it"
)});
count
();
}
function
count
()
{
document
.
querySelector
(
"#count"
).
innerHTML
=
watch
.
messages
().
length
;
}
</script>
...
...
rpc/message.go
View file @
af927ffd
...
...
@@ -287,7 +287,7 @@ func (req *RpcRequest) ToWhisperFilterArgs() (*xeth.Options, error) {
return
&
args
,
nil
}
func
(
req
*
RpcRequest
)
ToWhisper
Change
dArgs
()
(
int
,
error
)
{
func
(
req
*
RpcRequest
)
ToWhisper
I
dArgs
()
(
int
,
error
)
{
if
len
(
req
.
Params
)
<
1
{
return
0
,
NewErrorResponse
(
ErrorArguments
)
}
...
...
@@ -314,3 +314,17 @@ func (req *RpcRequest) ToWhisperPostArgs() (*WhisperMessageArgs, error) {
rpclogger
.
DebugDetailf
(
"%T %v"
,
args
,
args
)
return
&
args
,
nil
}
func
(
req
*
RpcRequest
)
ToWhisperHasIdentityArgs
()
(
string
,
error
)
{
if
len
(
req
.
Params
)
<
1
{
return
""
,
NewErrorResponse
(
ErrorArguments
)
}
var
args
string
err
:=
json
.
Unmarshal
(
req
.
Params
[
0
],
&
args
)
if
err
!=
nil
{
return
""
,
err
}
rpclogger
.
DebugDetailf
(
"%T %v"
,
args
,
args
)
return
args
,
nil
}
rpc/packages.go
View file @
af927ffd
...
...
@@ -299,6 +299,16 @@ func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{})
return
nil
}
func
(
p
*
EthereumApi
)
HasWhisperIdentity
(
args
string
,
reply
*
interface
{})
error
{
*
reply
=
p
.
xeth
.
Whisper
()
.
HasIdentity
(
args
)
return
nil
}
func
(
p
*
EthereumApi
)
WhisperMessages
(
id
int
,
reply
*
interface
{})
error
{
*
reply
=
p
.
xeth
.
Whisper
()
.
Messages
(
id
)
return
nil
}
func
(
p
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
// Spec at https://github.com/ethereum/wiki/wiki/Generic-ON-RPC
rpclogger
.
DebugDetailf
(
"%T %s"
,
req
.
Params
,
req
.
Params
)
...
...
@@ -405,7 +415,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return
p
.
NewWhisperFilter
(
args
,
reply
)
case
"shh_changed"
:
args
,
err
:=
req
.
ToWhisper
Change
dArgs
()
args
,
err
:=
req
.
ToWhisper
I
dArgs
()
if
err
!=
nil
{
return
err
}
...
...
@@ -413,9 +423,21 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case
"shh_post"
:
args
,
err
:=
req
.
ToWhisperPostArgs
()
if
err
!=
nil
{
return
nil
return
err
}
return
p
.
WhisperPost
(
args
,
reply
)
case
"shh_haveIdentity"
:
args
,
err
:=
req
.
ToWhisperHasIdentityArgs
()
if
err
!=
nil
{
return
err
}
return
p
.
HasWhisperIdentity
(
args
,
reply
)
case
"shh_getMessages"
:
args
,
err
:=
req
.
ToWhisperIdArgs
()
if
err
!=
nil
{
return
err
}
return
p
.
WhisperMessages
(
args
,
reply
)
default
:
return
NewErrorResponse
(
fmt
.
Sprintf
(
"%v %s"
,
ErrorNotImplemented
,
req
.
Method
))
}
...
...
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