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
19360c00
Commit
19360c00
authored
Mar 20, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move stateAt func to XEth
parent
6669ef5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
30 deletions
+24
-30
api.go
rpc/api.go
+6
-30
xeth.go
xeth/xeth.go
+18
-0
No files found.
rpc/api.go
View file @
19360c00
...
...
@@ -10,11 +10,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth"
)
...
...
@@ -53,28 +51,6 @@ func (self *EthereumApi) xeth() *xeth.XEth {
return
self
.
eth
}
func
(
self
*
EthereumApi
)
xethWithStateNum
(
num
int64
)
*
xeth
.
XEth
{
chain
:=
self
.
xeth
()
.
Backend
()
.
ChainManager
()
var
block
*
types
.
Block
if
num
<
0
{
num
=
chain
.
CurrentBlock
()
.
Number
()
.
Int64
()
+
num
+
1
}
block
=
chain
.
GetBlockByNumber
(
uint64
(
num
))
var
st
*
state
.
StateDB
if
block
!=
nil
{
st
=
state
.
New
(
block
.
Root
(),
self
.
xeth
()
.
Backend
()
.
StateDb
())
}
else
{
st
=
chain
.
State
()
}
return
self
.
xeth
()
.
WithState
(
st
)
}
func
(
self
*
EthereumApi
)
getStateWithNum
(
num
int64
)
*
xeth
.
State
{
return
self
.
xethWithStateNum
(
num
)
.
State
()
}
// func (self *EthereumApi) Register(args string, reply *interface{}) error {
// self.regmut.Lock()
// defer self.regmut.Unlock()
...
...
@@ -152,7 +128,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
}
func
(
p
*
EthereumApi
)
Call
(
args
*
NewTxArgs
,
reply
*
interface
{})
error
{
result
,
err
:=
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
result
,
err
:=
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
if
err
!=
nil
{
return
err
}
...
...
@@ -166,7 +142,7 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e
return
err
}
state
:=
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
state
:=
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
value
:=
state
.
StorageString
(
args
.
Key
)
var
hx
string
...
...
@@ -240,7 +216,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
err
}
*
reply
=
common
.
ToHex
(
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
.
Balance
()
.
Bytes
())
*
reply
=
common
.
ToHex
(
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
.
Balance
()
.
Bytes
())
case
"eth_getStorage"
,
"eth_storageAt"
:
args
:=
new
(
GetStorageArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -251,7 +227,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
err
}
*
reply
=
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
.
Storage
()
*
reply
=
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
State
()
.
SafeGet
(
args
.
Address
)
.
Storage
()
case
"eth_getStorageAt"
:
args
:=
new
(
GetStorageAtArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -269,7 +245,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
err
}
*
reply
=
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
TxCountAt
(
args
.
Address
)
*
reply
=
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
TxCountAt
(
args
.
Address
)
case
"eth_getBlockTransactionCountByHash"
:
args
:=
new
(
GetBlockByHashArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -314,7 +290,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
:=
args
.
requirements
();
err
!=
nil
{
return
err
}
*
reply
=
p
.
xeth
With
StateNum
(
args
.
BlockNumber
)
.
CodeAt
(
args
.
Address
)
*
reply
=
p
.
xeth
()
.
At
StateNum
(
args
.
BlockNumber
)
.
CodeAt
(
args
.
Address
)
case
"eth_sendTransaction"
,
"eth_transact"
:
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
xeth/xeth.go
View file @
19360c00
...
...
@@ -154,6 +154,24 @@ func (self *XEth) stop() {
close
(
self
.
quit
)
}
func
(
self
*
XEth
)
AtStateNum
(
num
int64
)
*
XEth
{
chain
:=
self
.
Backend
()
.
ChainManager
()
var
block
*
types
.
Block
if
num
<
0
{
num
=
chain
.
CurrentBlock
()
.
Number
()
.
Int64
()
+
num
+
1
}
block
=
chain
.
GetBlockByNumber
(
uint64
(
num
))
var
st
*
state
.
StateDB
if
block
!=
nil
{
st
=
state
.
New
(
block
.
Root
(),
self
.
Backend
()
.
StateDb
())
}
else
{
st
=
chain
.
State
()
}
return
self
.
WithState
(
st
)
}
func
(
self
*
XEth
)
Backend
()
Backend
{
return
self
.
eth
}
func
(
self
*
XEth
)
WithState
(
statedb
*
state
.
StateDB
)
*
XEth
{
xeth
:=
&
XEth
{
...
...
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