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
82b5a8af
Commit
82b5a8af
authored
Mar 24, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up height logic
parent
865f3101
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
31 deletions
+20
-31
xeth.go
xeth/xeth.go
+20
-31
No files found.
xeth/xeth.go
View file @
82b5a8af
...
...
@@ -116,22 +116,13 @@ 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
()
var
block
*
types
.
Block
// -1 generally means "latest"
// -2 means "pending", which has no blocknum
if
num
<
0
{
num
=
chain
.
CurrentBlock
()
.
Number
()
.
Int64
()
}
block
=
chain
.
GetBlockByNumber
(
uint64
(
num
))
block
:=
self
.
getBlockByHeight
(
num
)
var
st
*
state
.
StateDB
if
block
!=
nil
{
st
=
state
.
New
(
block
.
Root
(),
self
.
backend
.
StateDb
())
}
else
{
st
=
chain
.
State
()
st
=
self
.
backend
.
ChainManager
()
.
State
()
}
return
self
.
WithState
(
st
)
}
...
...
@@ -149,6 +140,22 @@ func (self *XEth) State() *State { return self.state }
func
(
self
*
XEth
)
Whisper
()
*
Whisper
{
return
self
.
whisper
}
func
(
self
*
XEth
)
getBlockByHeight
(
height
int64
)
*
types
.
Block
{
var
num
uint64
// -1 means "latest"
// -2 means "pending", which has no blocknum
if
height
<=
-
2
{
return
&
types
.
Block
{}
}
else
if
height
==
-
1
{
num
=
self
.
CurrentBlock
()
.
NumberU64
()
}
else
{
num
=
uint64
(
height
)
}
return
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
num
)
}
func
(
self
*
XEth
)
BlockByHash
(
strHash
string
)
*
Block
{
hash
:=
common
.
HexToHash
(
strHash
)
block
:=
self
.
backend
.
ChainManager
()
.
GetBlock
(
hash
)
...
...
@@ -172,29 +179,11 @@ func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
}
func
(
self
*
XEth
)
BlockByNumber
(
num
int64
)
*
Block
{
if
num
==
-
2
{
// "pending" is non-existant
return
&
Block
{}
}
if
num
==
-
1
{
return
NewBlock
(
self
.
CurrentBlock
())
}
return
NewBlock
(
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
)))
return
NewBlock
(
self
.
getBlockByHeight
(
num
))
}
func
(
self
*
XEth
)
EthBlockByNumber
(
num
int64
)
*
types
.
Block
{
if
num
==
-
2
{
// "pending" is non-existant
return
&
types
.
Block
{}
}
if
num
==
-
1
{
return
self
.
CurrentBlock
()
}
return
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
))
return
self
.
getBlockByHeight
(
num
)
}
func
(
self
*
XEth
)
CurrentBlock
()
*
types
.
Block
{
...
...
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