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
34689cb3
Commit
34689cb3
authored
Jan 12, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added manual triggering of filters
parent
8a1b51c7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
9 deletions
+51
-9
web3.js
cmd/mist/assets/ext/ethereum.js/lib/web3.js
+1
-1
browser.qml
cmd/mist/assets/qml/browser.qml
+8
-1
filter.go
event/filter/filter.go
+8
-0
whisper.go
ui/qt/qwhisper/whisper.go
+4
-0
whisper.go
whisper/whisper.go
+30
-7
No files found.
cmd/mist/assets/ext/ethereum.js/lib/web3.js
View file @
34689cb3
...
@@ -150,7 +150,7 @@ var shhWatchMethods = function () {
...
@@ -150,7 +150,7 @@ var shhWatchMethods = function () {
return
[
return
[
{
name
:
'newFilter'
,
call
:
'shh_newFilter'
},
{
name
:
'newFilter'
,
call
:
'shh_newFilter'
},
{
name
:
'uninstallFilter'
,
call
:
'shh_uninstallFilter'
},
{
name
:
'uninstallFilter'
,
call
:
'shh_uninstallFilter'
},
{
name
:
'getMessage'
,
call
:
'shh_getMessages'
}
{
name
:
'getMessage
s
'
,
call
:
'shh_getMessages'
}
];
];
};
};
...
...
cmd/mist/assets/qml/browser.qml
View file @
34689cb3
...
@@ -310,7 +310,7 @@ Rectangle {
...
@@ -310,7 +310,7 @@ Rectangle {
postData
(
data
.
_id
,
id
);
postData
(
data
.
_id
,
id
);
break
;
break
;
case
"eth_
message
s"
:
case
"eth_
filterLog
s"
:
require
(
1
);
require
(
1
);
var
messages
=
eth
.
messages
(
data
.
args
[
0
]);
var
messages
=
eth
.
messages
(
data
.
args
[
0
]);
...
@@ -352,6 +352,13 @@ Rectangle {
...
@@ -352,6 +352,13 @@ Rectangle {
shh
.
post
(
params
.
payload
,
params
.
to
,
params
.
from
,
params
.
topics
,
params
.
priority
,
params
.
ttl
);
shh
.
post
(
params
.
payload
,
params
.
to
,
params
.
from
,
params
.
topics
,
params
.
priority
,
params
.
ttl
);
break
;
case
"shh_getMessages"
:
require
(
1
);
shh
.
trigger
(
data
.
args
[
0
]);
break
;
break
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
event/filter/filter.go
View file @
34689cb3
...
@@ -68,3 +68,11 @@ out:
...
@@ -68,3 +68,11 @@ out:
}
}
}
}
}
}
func
(
self
*
Filters
)
Match
(
a
,
b
Filter
)
bool
{
return
reflect
.
TypeOf
(
a
)
==
reflect
.
TypeOf
(
b
)
&&
a
.
Compare
(
b
)
}
func
(
self
*
Filters
)
Get
(
i
int
)
Filter
{
return
self
.
watchers
[
i
]
}
ui/qt/qwhisper/whisper.go
View file @
34689cb3
...
@@ -84,6 +84,10 @@ func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int {
...
@@ -84,6 +84,10 @@ func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int {
return
i
return
i
}
}
func
(
self
*
Whisper
)
Trigger
(
id
int
)
{
go
self
.
Whisper
.
Trigger
(
id
)
}
func
filterFromMap
(
opts
map
[
string
]
interface
{})
(
f
whisper
.
Filter
)
{
func
filterFromMap
(
opts
map
[
string
]
interface
{})
(
f
whisper
.
Filter
)
{
if
to
,
ok
:=
opts
[
"to"
]
.
(
string
);
ok
{
if
to
,
ok
:=
opts
[
"to"
]
.
(
string
);
ok
{
f
.
To
=
crypto
.
ToECDSA
(
fromHex
(
to
))
f
.
To
=
crypto
.
ToECDSA
(
fromHex
(
to
))
...
...
whisper/whisper.go
View file @
34689cb3
...
@@ -126,6 +126,20 @@ func (self *Whisper) Watch(opts Filter) int {
...
@@ -126,6 +126,20 @@ func (self *Whisper) Watch(opts Filter) int {
})
})
}
}
func
(
self
*
Whisper
)
Trigger
(
id
int
)
{
filter
:=
self
.
filters
.
Get
(
id
)
if
filter
!=
nil
{
for
_
,
e
:=
range
self
.
messages
{
if
msg
,
key
:=
self
.
open
(
e
);
msg
!=
nil
{
f
:=
createFilter
(
msg
,
e
.
Topics
,
key
)
if
self
.
filters
.
Match
(
filter
,
f
)
{
self
.
filters
.
Notify
(
f
,
msg
)
}
}
}
}
}
// Main handler for passing whisper messages to whisper peer objects
// Main handler for passing whisper messages to whisper peer objects
func
(
self
*
Whisper
)
msgHandler
(
peer
*
p2p
.
Peer
,
ws
p2p
.
MsgReadWriter
)
error
{
func
(
self
*
Whisper
)
msgHandler
(
peer
*
p2p
.
Peer
,
ws
p2p
.
MsgReadWriter
)
error
{
wpeer
:=
NewPeer
(
self
,
peer
,
ws
)
wpeer
:=
NewPeer
(
self
,
peer
,
ws
)
...
@@ -227,19 +241,28 @@ func (self *Whisper) envelopes() (envelopes []*Envelope) {
...
@@ -227,19 +241,28 @@ func (self *Whisper) envelopes() (envelopes []*Envelope) {
}
}
func
(
self
*
Whisper
)
postEvent
(
envelope
*
Envelope
)
{
func
(
self
*
Whisper
)
postEvent
(
envelope
*
Envelope
)
{
if
message
,
key
:=
self
.
open
(
envelope
);
message
!=
nil
{
self
.
filters
.
Notify
(
createFilter
(
message
,
envelope
.
Topics
,
key
),
message
)
}
}
func
(
self
*
Whisper
)
open
(
envelope
*
Envelope
)
(
*
Message
,
*
ecdsa
.
PrivateKey
)
{
for
_
,
key
:=
range
self
.
keys
{
for
_
,
key
:=
range
self
.
keys
{
if
message
,
err
:=
envelope
.
Open
(
key
);
err
==
nil
||
(
err
!=
nil
&&
err
==
ecies
.
ErrInvalidPublicKey
)
{
if
message
,
err
:=
envelope
.
Open
(
key
);
err
==
nil
||
(
err
!=
nil
&&
err
==
ecies
.
ErrInvalidPublicKey
)
{
self
.
filters
.
Notify
(
filter
.
Generic
{
return
message
,
key
Str1
:
string
(
crypto
.
FromECDSA
(
key
)),
Str2
:
string
(
crypto
.
FromECDSAPub
(
message
.
Recover
())),
Data
:
bytesToMap
(
envelope
.
Topics
),
},
message
)
break
}
else
{
wlogger
.
Infoln
(
err
)
}
}
}
}
return
nil
,
nil
}
}
func
(
self
*
Whisper
)
Protocol
()
p2p
.
Protocol
{
func
(
self
*
Whisper
)
Protocol
()
p2p
.
Protocol
{
return
self
.
protocol
return
self
.
protocol
}
}
func
createFilter
(
message
*
Message
,
topics
[][]
byte
,
key
*
ecdsa
.
PrivateKey
)
filter
.
Filter
{
return
filter
.
Generic
{
Str1
:
string
(
crypto
.
FromECDSA
(
key
)),
Str2
:
string
(
crypto
.
FromECDSAPub
(
message
.
Recover
())),
Data
:
bytesToMap
(
topics
),
}
}
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