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
1fae50a1
Unverified
Commit
1fae50a1
authored
7 years ago
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: minor evm polishes and optimizations
parent
933972d1
master
v1.10.12
v1.10.12-modified
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
101 deletions
+107
-101
evm.go
core/evm.go
+16
-3
headerchain.go
core/headerchain.go
+1
-1
instructions.go
core/vm/instructions.go
+76
-95
intpool.go
core/vm/intpool.go
+14
-2
No files found.
core/evm.go
View file @
1fae50a1
...
...
@@ -60,13 +60,26 @@ func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author
// GetHashFn returns a GetHashFunc which retrieves header hashes by number
func
GetHashFn
(
ref
*
types
.
Header
,
chain
ChainContext
)
func
(
n
uint64
)
common
.
Hash
{
var
cache
map
[
uint64
]
common
.
Hash
return
func
(
n
uint64
)
common
.
Hash
{
// If there's no hash cache yet, make one
if
cache
==
nil
{
cache
=
map
[
uint64
]
common
.
Hash
{
ref
.
Number
.
Uint64
()
-
1
:
ref
.
ParentHash
,
}
}
// Try to fulfill the request from the cache
if
hash
,
ok
:=
cache
[
n
];
ok
{
return
hash
}
// Not cached, iterate the blocks and cache the hashes
for
header
:=
chain
.
GetHeader
(
ref
.
ParentHash
,
ref
.
Number
.
Uint64
()
-
1
);
header
!=
nil
;
header
=
chain
.
GetHeader
(
header
.
ParentHash
,
header
.
Number
.
Uint64
()
-
1
)
{
if
header
.
Number
.
Uint64
()
==
n
{
return
header
.
Hash
()
cache
[
header
.
Number
.
Uint64
()
-
1
]
=
header
.
ParentHash
if
n
==
header
.
Number
.
Uint64
()
-
1
{
return
header
.
ParentHash
}
}
return
common
.
Hash
{}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/headerchain.go
View file @
1fae50a1
...
...
@@ -23,6 +23,7 @@ import (
"math"
"math/big"
mrand
"math/rand"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -32,7 +33,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/hashicorp/golang-lru"
"sync/atomic"
)
const
(
...
...
This diff is collapsed.
Click to expand it.
core/vm/instructions.go
View file @
1fae50a1
This diff is collapsed.
Click to expand it.
core/vm/intpool.go
View file @
1fae50a1
...
...
@@ -32,24 +32,36 @@ func newIntPool() *intPool {
return
&
intPool
{
pool
:
newstack
()}
}
// get retrieves a big int from the pool, allocating one if the pool is empty.
// Note, the returned int's value is arbitrary and will not be zeroed!
func
(
p
*
intPool
)
get
()
*
big
.
Int
{
if
p
.
pool
.
len
()
>
0
{
return
p
.
pool
.
pop
()
}
return
new
(
big
.
Int
)
}
// getZero retrieves a big int from the pool, setting it to zero or allocating
// a new one if the pool is empty.
func
(
p
*
intPool
)
getZero
()
*
big
.
Int
{
if
p
.
pool
.
len
()
>
0
{
return
p
.
pool
.
pop
()
.
SetUint64
(
0
)
}
return
new
(
big
.
Int
)
}
// put returns an allocated big int to the pool to be later reused by get calls.
// Note, the values as saved as is; neither put nor get zeroes the ints out!
func
(
p
*
intPool
)
put
(
is
...*
big
.
Int
)
{
if
len
(
p
.
pool
.
data
)
>
poolLimit
{
return
}
for
_
,
i
:=
range
is
{
// verifyPool is a build flag. Pool verification makes sure the integrity
// of the integer pool by comparing values to a default value.
if
verifyPool
{
i
.
Set
(
checkVal
)
}
p
.
pool
.
push
(
i
)
}
}
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