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
dba15d9c
Commit
dba15d9c
authored
Oct 21, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1918 from obscuren/get-hash-fix
core, tests: get_hash fix
parents
796952a4
80f26086
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
environment.go
core/vm/environment.go
+1
-1
vm_env.go
core/vm_env.go
+4
-2
util.go
tests/util.go
+5
-7
No files found.
core/vm/environment.go
View file @
dba15d9c
...
...
@@ -39,7 +39,7 @@ type Environment interface {
// The block number this VM is invoken on
BlockNumber
()
*
big
.
Int
// The n'th hash ago from this block number
GetHash
(
n
uint64
)
common
.
Hash
GetHash
(
uint64
)
common
.
Hash
// The handler's address
Coinbase
()
common
.
Address
// The current time (block time)
...
...
core/vm_env.go
View file @
dba15d9c
...
...
@@ -59,8 +59,10 @@ func (self *VMEnv) SetDepth(i int) { self.depth = i }
func
(
self
*
VMEnv
)
VmType
()
vm
.
Type
{
return
self
.
typ
}
func
(
self
*
VMEnv
)
SetVmType
(
t
vm
.
Type
)
{
self
.
typ
=
t
}
func
(
self
*
VMEnv
)
GetHash
(
n
uint64
)
common
.
Hash
{
if
block
:=
self
.
chain
.
GetBlockByNumber
(
n
);
block
!=
nil
{
return
block
.
Hash
()
for
block
:=
self
.
chain
.
GetBlock
(
self
.
header
.
ParentHash
);
block
!=
nil
;
block
=
self
.
chain
.
GetBlock
(
block
.
ParentHash
())
{
if
block
.
NumberU64
()
==
n
{
return
block
.
Hash
()
}
}
return
common
.
Hash
{}
...
...
tests/util.go
View file @
dba15d9c
...
...
@@ -131,8 +131,8 @@ type Env struct {
initial
bool
Gas
*
big
.
Int
origin
common
.
Address
//
parent common.Hash
origin
common
.
Address
parent
common
.
Hash
coinbase
common
.
Address
number
*
big
.
Int
...
...
@@ -163,7 +163,7 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
env
:=
NewEnv
(
state
)
env
.
origin
=
common
.
HexToAddress
(
exeValues
[
"caller"
])
//env.parent = common.Hex2Bytes
(envValues["previousHash"])
env
.
parent
=
common
.
HexToHash
(
envValues
[
"previousHash"
])
env
.
coinbase
=
common
.
HexToAddress
(
envValues
[
"currentCoinbase"
])
env
.
number
=
common
.
Big
(
envValues
[
"currentNumber"
])
env
.
time
=
common
.
Big
(
envValues
[
"currentTimestamp"
])
...
...
@@ -174,10 +174,8 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
return
env
}
func
(
self
*
Env
)
Origin
()
common
.
Address
{
return
self
.
origin
}
func
(
self
*
Env
)
BlockNumber
()
*
big
.
Int
{
return
self
.
number
}
//func (self *Env) PrevHash() []byte { return self.parent }
func
(
self
*
Env
)
Origin
()
common
.
Address
{
return
self
.
origin
}
func
(
self
*
Env
)
BlockNumber
()
*
big
.
Int
{
return
self
.
number
}
func
(
self
*
Env
)
Coinbase
()
common
.
Address
{
return
self
.
coinbase
}
func
(
self
*
Env
)
Time
()
*
big
.
Int
{
return
self
.
time
}
func
(
self
*
Env
)
Difficulty
()
*
big
.
Int
{
return
self
.
difficulty
}
...
...
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