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
43d521e9
Commit
43d521e9
authored
Mar 27, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple core from rpc
parent
0ac346f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
62 deletions
+34
-62
filter.go
core/filter.go
+0
-23
api.go
rpc/api.go
+2
-35
xeth.go
xeth/xeth.go
+32
-4
No files found.
core/filter.go
View file @
43d521e9
...
...
@@ -12,17 +12,6 @@ type AccountChange struct {
Address
,
StateAddress
[]
byte
}
type
FilterOptions
struct
{
Earliest
int64
Latest
int64
Address
[]
common
.
Address
Topics
[][]
common
.
Hash
Skip
int
Max
int
}
// Filtering interface
type
Filter
struct
{
eth
Backend
...
...
@@ -44,18 +33,6 @@ func NewFilter(eth Backend) *Filter {
return
&
Filter
{
eth
:
eth
}
}
// SetOptions copies the filter options to the filter it self. The reason for this "silly" copy
// is simply because named arguments in this case is extremely nice and readable.
func
(
self
*
Filter
)
SetOptions
(
options
*
FilterOptions
)
{
self
.
earliest
=
options
.
Earliest
self
.
latest
=
options
.
Latest
self
.
skip
=
options
.
Skip
self
.
max
=
options
.
Max
self
.
address
=
options
.
Address
self
.
topics
=
options
.
Topics
}
// Set the earliest and latest block for filtering.
// -1 = latest block (i.e., the current block)
// hash = particular hash from-to
...
...
rpc/api.go
View file @
43d521e9
...
...
@@ -6,7 +6,6 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/xeth"
)
...
...
@@ -277,8 +276,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
}
opts
:=
toFilterOptions
(
args
)
id
:=
api
.
xeth
()
.
RegisterFilter
(
opts
)
id
:=
api
.
xeth
()
.
RegisterFilter
(
args
.
Earliest
,
args
.
Latest
,
args
.
Skip
,
args
.
Max
,
args
.
Address
,
args
.
Topics
)
*
reply
=
common
.
ToHex
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
case
"eth_newBlockFilter"
:
args
:=
new
(
FilterStringArgs
)
...
...
@@ -310,8 +308,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
}
opts
:=
toFilterOptions
(
args
)
*
reply
=
NewLogsRes
(
api
.
xeth
()
.
AllLogs
(
opts
))
*
reply
=
NewLogsRes
(
api
.
xeth
()
.
AllLogs
(
args
.
Earliest
,
args
.
Latest
,
args
.
Skip
,
args
.
Max
,
args
.
Address
,
args
.
Topics
))
case
"eth_getWork"
:
api
.
xeth
()
.
SetMining
(
true
)
*
reply
=
api
.
xeth
()
.
RemoteMining
()
.
GetWork
()
...
...
@@ -456,33 +453,3 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
rpclogger
.
DebugDetailf
(
"Reply: %T %s"
,
reply
,
reply
)
return
nil
}
func
toFilterOptions
(
options
*
BlockFilterArgs
)
*
core
.
FilterOptions
{
var
opts
core
.
FilterOptions
opts
.
Address
=
cAddress
(
options
.
Address
)
opts
.
Topics
=
cTopics
(
options
.
Topics
)
opts
.
Earliest
=
options
.
Earliest
opts
.
Latest
=
options
.
Latest
return
&
opts
}
func
cAddress
(
a
[]
string
)
[]
common
.
Address
{
bslice
:=
make
([]
common
.
Address
,
len
(
a
))
for
i
,
addr
:=
range
a
{
bslice
[
i
]
=
common
.
HexToAddress
(
addr
)
}
return
bslice
}
func
cTopics
(
t
[][]
string
)
[][]
common
.
Hash
{
topics
:=
make
([][]
common
.
Hash
,
len
(
t
))
for
i
,
iv
:=
range
t
{
for
j
,
jv
:=
range
iv
{
topics
[
i
][
j
]
=
common
.
HexToHash
(
jv
)
}
}
return
topics
}
xeth/xeth.go
View file @
43d521e9
...
...
@@ -110,6 +110,24 @@ func (self *XEth) stop() {
close
(
self
.
quit
)
}
func
cAddress
(
a
[]
string
)
[]
common
.
Address
{
bslice
:=
make
([]
common
.
Address
,
len
(
a
))
for
i
,
addr
:=
range
a
{
bslice
[
i
]
=
common
.
HexToAddress
(
addr
)
}
return
bslice
}
func
cTopics
(
t
[][]
string
)
[][]
common
.
Hash
{
topics
:=
make
([][]
common
.
Hash
,
len
(
t
))
for
i
,
iv
:=
range
t
{
for
j
,
jv
:=
range
iv
{
topics
[
i
][
j
]
=
common
.
HexToHash
(
jv
)
}
}
return
topics
}
func
(
self
*
XEth
)
DefaultGas
()
*
big
.
Int
{
return
defaultGas
}
func
(
self
*
XEth
)
DefaultGasPrice
()
*
big
.
Int
{
return
defaultGasPrice
}
...
...
@@ -301,10 +319,15 @@ func (self *XEth) SecretToAddress(key string) string {
return
common
.
ToHex
(
pair
.
Address
())
}
func
(
self
*
XEth
)
RegisterFilter
(
args
*
core
.
FilterOptions
)
int
{
func
(
self
*
XEth
)
RegisterFilter
(
earliest
,
latest
int64
,
skip
,
max
int
,
address
[]
string
,
topics
[][]
string
)
int
{
var
id
int
filter
:=
core
.
NewFilter
(
self
.
backend
)
filter
.
SetOptions
(
args
)
filter
.
SetEarliestBlock
(
earliest
)
filter
.
SetLatestBlock
(
latest
)
filter
.
SetSkip
(
skip
)
filter
.
SetMax
(
max
)
filter
.
SetAddress
(
cAddress
(
address
))
filter
.
SetTopics
(
cTopics
(
topics
))
filter
.
LogsCallback
=
func
(
logs
state
.
Logs
)
{
self
.
logMut
.
Lock
()
defer
self
.
logMut
.
Unlock
()
...
...
@@ -380,9 +403,14 @@ func (self *XEth) Logs(id int) state.Logs {
return
nil
}
func
(
self
*
XEth
)
AllLogs
(
args
*
core
.
FilterOptions
)
state
.
Logs
{
func
(
self
*
XEth
)
AllLogs
(
earliest
,
latest
int64
,
skip
,
max
int
,
address
[]
string
,
topics
[][]
string
)
state
.
Logs
{
filter
:=
core
.
NewFilter
(
self
.
backend
)
filter
.
SetOptions
(
args
)
filter
.
SetEarliestBlock
(
earliest
)
filter
.
SetLatestBlock
(
latest
)
filter
.
SetSkip
(
skip
)
filter
.
SetMax
(
max
)
filter
.
SetAddress
(
cAddress
(
address
))
filter
.
SetTopics
(
cTopics
(
topics
))
return
filter
.
Find
()
}
...
...
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