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
7e160a67
Commit
7e160a67
authored
May 06, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xeth, core, event/filter, rpc: new block and transaction filters
parent
97c37356
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
83 deletions
+198
-83
filter.go
core/filter.go
+3
-3
eth_filter.go
event/filter/eth_filter.go
+2
-2
api.go
rpc/api.go
+16
-7
responses.go
rpc/responses.go
+11
-0
xeth.go
xeth/xeth.go
+166
-71
No files found.
core/filter.go
View file @
7e160a67
...
@@ -22,9 +22,9 @@ type Filter struct {
...
@@ -22,9 +22,9 @@ type Filter struct {
max
int
max
int
topics
[][]
common
.
Hash
topics
[][]
common
.
Hash
BlockCallback
func
(
*
types
.
Block
,
state
.
Logs
)
BlockCallback
func
(
*
types
.
Block
,
state
.
Logs
)
Pending
Callback
func
(
*
types
.
Transaction
)
Transaction
Callback
func
(
*
types
.
Transaction
)
LogsCallback
func
(
state
.
Logs
)
LogsCallback
func
(
state
.
Logs
)
}
}
// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block
// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block
...
...
event/filter/eth_filter.go
View file @
7e160a67
...
@@ -88,8 +88,8 @@ out:
...
@@ -88,8 +88,8 @@ out:
case
core
.
TxPreEvent
:
case
core
.
TxPreEvent
:
self
.
filterMu
.
RLock
()
self
.
filterMu
.
RLock
()
for
_
,
filter
:=
range
self
.
filters
{
for
_
,
filter
:=
range
self
.
filters
{
if
filter
.
Pending
Callback
!=
nil
{
if
filter
.
Transaction
Callback
!=
nil
{
filter
.
Pending
Callback
(
event
.
Tx
)
filter
.
Transaction
Callback
(
event
.
Tx
)
}
}
}
}
self
.
filterMu
.
RUnlock
()
self
.
filterMu
.
RUnlock
()
...
...
rpc/api.go
View file @
7e160a67
...
@@ -322,14 +322,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -322,14 +322,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
return
err
}
}
id
:=
api
.
xeth
()
.
Register
Filter
(
args
.
Earliest
,
args
.
Latest
,
args
.
Skip
,
args
.
Max
,
args
.
Address
,
args
.
Topics
)
id
:=
api
.
xeth
()
.
NewLog
Filter
(
args
.
Earliest
,
args
.
Latest
,
args
.
Skip
,
args
.
Max
,
args
.
Address
,
args
.
Topics
)
*
reply
=
newHexNum
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
*
reply
=
newHexNum
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
case
"eth_newBlockFilter"
:
case
"eth_newBlockFilter"
:
args
:=
new
(
FilterStringArgs
)
*
reply
=
newHexNum
(
api
.
xeth
()
.
NewBlockFilter
())
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
case
"eth_transactionFilter"
:
return
err
*
reply
=
newHexNum
(
api
.
xeth
()
.
NewTransactionFilter
())
}
*
reply
=
newHexNum
(
api
.
xeth
()
.
NewFilterString
(
args
.
Word
))
case
"eth_uninstallFilter"
:
case
"eth_uninstallFilter"
:
args
:=
new
(
FilterIdArgs
)
args
:=
new
(
FilterIdArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -341,7 +340,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -341,7 +340,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
NewLogsRes
(
api
.
xeth
()
.
FilterChanged
(
args
.
Id
))
switch
api
.
xeth
()
.
GetFilterType
(
args
.
Id
)
{
case
xeth
.
BlockFilterTy
:
*
reply
=
NewHashesRes
(
api
.
xeth
()
.
BlockFilterChanged
(
args
.
Id
))
case
xeth
.
TransactionFilterTy
:
*
reply
=
NewHashesRes
(
api
.
xeth
()
.
TransactionFilterChanged
(
args
.
Id
))
case
xeth
.
LogFilterTy
:
*
reply
=
NewLogsRes
(
api
.
xeth
()
.
LogFilterChanged
(
args
.
Id
))
default
:
*
reply
=
[]
string
{}
// reply empty string slice
}
case
"eth_getFilterLogs"
:
case
"eth_getFilterLogs"
:
args
:=
new
(
FilterIdArgs
)
args
:=
new
(
FilterIdArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/responses.go
View file @
7e160a67
...
@@ -3,6 +3,7 @@ package rpc
...
@@ -3,6 +3,7 @@ package rpc
import
(
import
(
"encoding/json"
"encoding/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
)
)
...
@@ -303,3 +304,13 @@ func NewLogsRes(logs state.Logs) (ls []LogRes) {
...
@@ -303,3 +304,13 @@ func NewLogsRes(logs state.Logs) (ls []LogRes) {
return
return
}
}
func
NewHashesRes
(
hs
[]
common
.
Hash
)
[]
string
{
hashes
:=
make
([]
string
,
len
(
hs
))
for
i
,
hash
:=
range
hs
{
hashes
[
i
]
=
hash
.
Hex
()
}
return
hashes
}
xeth/xeth.go
View file @
7e160a67
This diff is collapsed.
Click to expand it.
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