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
59b6b619
Commit
59b6b619
authored
10 years ago
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't expose backend directly
parent
b9b7442b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
api.go
rpc/api.go
+3
-3
xeth.go
xeth/xeth.go
+17
-6
No files found.
rpc/api.go
View file @
59b6b619
...
...
@@ -60,9 +60,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
*
reply
=
common
.
ToHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
case
"web3_clientVersion"
:
*
reply
=
api
.
xeth
()
.
Backend
()
.
Version
()
*
reply
=
api
.
xeth
()
.
Client
Version
()
case
"net_version"
:
*
reply
=
string
(
api
.
xeth
()
.
Backend
()
.
ProtocolVersion
()
)
*
reply
=
api
.
xeth
()
.
NetworkVersion
(
)
case
"net_listening"
:
*
reply
=
api
.
xeth
()
.
IsListening
()
case
"net_peerCount"
:
...
...
@@ -84,7 +84,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case
"eth_accounts"
:
*
reply
=
api
.
xeth
()
.
Accounts
()
case
"eth_blockNumber"
:
v
:=
api
.
xeth
()
.
Backend
()
.
ChainManager
()
.
CurrentBlock
()
.
Number
()
v
:=
api
.
xeth
()
.
CurrentBlock
()
.
Number
()
*
reply
=
common
.
ToHex
(
v
.
Bytes
())
case
"eth_getBalance"
:
args
:=
new
(
GetBalanceArgs
)
...
...
This diff is collapsed.
Click to expand it.
xeth/xeth.go
View file @
59b6b619
...
...
@@ -143,7 +143,7 @@ func (self *XEth) DefaultGasPrice() *big.Int { return defaultGasPrice }
func
(
self
*
XEth
)
RemoteMining
()
*
miner
.
RemoteAgent
{
return
self
.
agent
}
func
(
self
*
XEth
)
AtStateNum
(
num
int64
)
*
XEth
{
chain
:=
self
.
Backend
()
.
ChainManager
()
chain
:=
self
.
backend
.
ChainManager
()
var
block
*
types
.
Block
// -1 generally means "latest"
...
...
@@ -156,14 +156,13 @@ func (self *XEth) AtStateNum(num int64) *XEth {
var
st
*
state
.
StateDB
if
block
!=
nil
{
st
=
state
.
New
(
block
.
Root
(),
self
.
Backend
()
.
StateDb
())
st
=
state
.
New
(
block
.
Root
(),
self
.
backend
.
StateDb
())
}
else
{
st
=
chain
.
State
()
}
return
self
.
WithState
(
st
)
}
func
(
self
*
XEth
)
Backend
()
*
eth
.
Ethereum
{
return
self
.
backend
}
func
(
self
*
XEth
)
WithState
(
statedb
*
state
.
StateDB
)
*
XEth
{
xeth
:=
&
XEth
{
backend
:
self
.
backend
,
...
...
@@ -224,6 +223,10 @@ func (self *XEth) EthBlockByNumber(num int64) *types.Block {
return
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
))
}
func
(
self
*
XEth
)
CurrentBlock
()
*
types
.
Block
{
return
self
.
backend
.
ChainManager
()
.
CurrentBlock
()
}
func
(
self
*
XEth
)
Block
(
v
interface
{})
*
Block
{
if
n
,
ok
:=
v
.
(
int32
);
ok
{
return
self
.
BlockByNumber
(
int64
(
n
))
...
...
@@ -254,6 +257,14 @@ func (self *XEth) IsMining() bool {
return
self
.
backend
.
IsMining
()
}
func
(
self
*
XEth
)
NetworkVersion
()
string
{
return
string
(
self
.
backend
.
ProtocolVersion
())
}
func
(
self
*
XEth
)
ClientVersion
()
string
{
return
self
.
backend
.
Version
()
}
func
(
self
*
XEth
)
SetMining
(
shouldmine
bool
)
bool
{
ismining
:=
self
.
backend
.
IsMining
()
if
shouldmine
&&
!
ismining
{
...
...
@@ -314,7 +325,7 @@ func (self *XEth) SecretToAddress(key string) string {
func
(
self
*
XEth
)
RegisterFilter
(
args
*
core
.
FilterOptions
)
int
{
var
id
int
filter
:=
core
.
NewFilter
(
self
.
Backend
()
)
filter
:=
core
.
NewFilter
(
self
.
backend
)
filter
.
SetOptions
(
args
)
filter
.
LogsCallback
=
func
(
logs
state
.
Logs
)
{
self
.
logMut
.
Lock
()
...
...
@@ -340,7 +351,7 @@ func (self *XEth) UninstallFilter(id int) bool {
func
(
self
*
XEth
)
NewFilterString
(
word
string
)
int
{
var
id
int
filter
:=
core
.
NewFilter
(
self
.
Backend
()
)
filter
:=
core
.
NewFilter
(
self
.
backend
)
switch
word
{
case
"pending"
:
...
...
@@ -392,7 +403,7 @@ func (self *XEth) Logs(id int) state.Logs {
}
func
(
self
*
XEth
)
AllLogs
(
args
*
core
.
FilterOptions
)
state
.
Logs
{
filter
:=
core
.
NewFilter
(
self
.
Backend
()
)
filter
:=
core
.
NewFilter
(
self
.
backend
)
filter
.
SetOptions
(
args
)
return
filter
.
Find
()
...
...
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