good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
82b5a8af
Commit
82b5a8af
authored
Mar 24, 2015
by
Taylor Gerring
Browse files
Options
Downloads
Patches
Plain Diff
DRY up height logic
parent
865f3101
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
xeth/xeth.go
+20
-31
20 additions, 31 deletions
xeth/xeth.go
with
20 additions
and
31 deletions
xeth/xeth.go
+
20
−
31
View file @
82b5a8af
...
@@ -116,22 +116,13 @@ func (self *XEth) DefaultGasPrice() *big.Int { return defaultGasPrice }
...
@@ -116,22 +116,13 @@ func (self *XEth) DefaultGasPrice() *big.Int { return defaultGasPrice }
func
(
self
*
XEth
)
RemoteMining
()
*
miner
.
RemoteAgent
{
return
self
.
agent
}
func
(
self
*
XEth
)
RemoteMining
()
*
miner
.
RemoteAgent
{
return
self
.
agent
}
func
(
self
*
XEth
)
AtStateNum
(
num
int64
)
*
XEth
{
func
(
self
*
XEth
)
AtStateNum
(
num
int64
)
*
XEth
{
chain
:=
self
.
backend
.
ChainManager
()
block
:=
self
.
getBlockByHeight
(
num
)
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
))
var
st
*
state
.
StateDB
var
st
*
state
.
StateDB
if
block
!=
nil
{
if
block
!=
nil
{
st
=
state
.
New
(
block
.
Root
(),
self
.
backend
.
StateDb
())
st
=
state
.
New
(
block
.
Root
(),
self
.
backend
.
StateDb
())
}
else
{
}
else
{
st
=
chain
.
State
()
st
=
self
.
backend
.
ChainManager
()
.
State
()
}
}
return
self
.
WithState
(
st
)
return
self
.
WithState
(
st
)
}
}
...
@@ -149,6 +140,22 @@ func (self *XEth) State() *State { return self.state }
...
@@ -149,6 +140,22 @@ func (self *XEth) State() *State { return self.state }
func
(
self
*
XEth
)
Whisper
()
*
Whisper
{
return
self
.
whisper
}
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
{
func
(
self
*
XEth
)
BlockByHash
(
strHash
string
)
*
Block
{
hash
:=
common
.
HexToHash
(
strHash
)
hash
:=
common
.
HexToHash
(
strHash
)
block
:=
self
.
backend
.
ChainManager
()
.
GetBlock
(
hash
)
block
:=
self
.
backend
.
ChainManager
()
.
GetBlock
(
hash
)
...
@@ -172,29 +179,11 @@ func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
...
@@ -172,29 +179,11 @@ func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
}
}
func
(
self
*
XEth
)
BlockByNumber
(
num
int64
)
*
Block
{
func
(
self
*
XEth
)
BlockByNumber
(
num
int64
)
*
Block
{
if
num
==
-
2
{
return
NewBlock
(
self
.
getBlockByHeight
(
num
))
// "pending" is non-existant
return
&
Block
{}
}
if
num
==
-
1
{
return
NewBlock
(
self
.
CurrentBlock
())
}
return
NewBlock
(
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
)))
}
}
func
(
self
*
XEth
)
EthBlockByNumber
(
num
int64
)
*
types
.
Block
{
func
(
self
*
XEth
)
EthBlockByNumber
(
num
int64
)
*
types
.
Block
{
if
num
==
-
2
{
return
self
.
getBlockByHeight
(
num
)
// "pending" is non-existant
return
&
types
.
Block
{}
}
if
num
==
-
1
{
return
self
.
CurrentBlock
()
}
return
self
.
backend
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
))
}
}
func
(
self
*
XEth
)
CurrentBlock
()
*
types
.
Block
{
func
(
self
*
XEth
)
CurrentBlock
()
*
types
.
Block
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment