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
905b8cc8
Commit
905b8cc8
authored
Jan 09, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mem fixes for vm. Changed uncle inclusion tests
parent
35f4bb96
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
14 deletions
+46
-14
block_processor.go
core/block_processor.go
+20
-14
chain_manager.go
core/chain_manager.go
+22
-0
stack.go
vm/stack.go
+4
-0
No files found.
core/block_processor.go
View file @
905b8cc8
...
...
@@ -294,32 +294,38 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error {
func
(
sm
*
BlockProcessor
)
AccumelateRewards
(
statedb
*
state
.
StateDB
,
block
,
parent
*
types
.
Block
)
error
{
reward
:=
new
(
big
.
Int
)
.
Set
(
BlockReward
)
knownUncle
s
:=
set
.
New
()
for
_
,
uncle
:=
range
parent
.
Uncles
(
)
{
knownUncles
.
Add
(
string
(
uncle
.
Hash
()))
ancestor
s
:=
set
.
New
()
for
_
,
ancestor
:=
range
sm
.
bc
.
GetAncestors
(
block
,
6
)
{
ancestors
.
Add
(
string
(
ancestor
.
Hash
()))
}
nonces
:=
ethutil
.
NewSet
(
block
.
Header
()
.
Nonce
)
uncles
:=
set
.
New
()
uncles
.
Add
(
string
(
block
.
Hash
()))
for
_
,
uncle
:=
range
block
.
Uncles
()
{
if
nonces
.
Include
(
uncle
.
Nonce
)
{
if
uncles
.
Has
(
string
(
uncle
.
Hash
())
)
{
// Error not unique
return
UncleError
(
"Uncle not unique"
)
}
uncles
.
Add
(
string
(
uncle
.
Hash
()))
uncleParent
:=
sm
.
bc
.
GetBlock
(
uncle
.
ParentHash
)
if
uncleParent
==
nil
{
if
!
ancestors
.
Has
(
uncle
.
ParentHash
)
{
return
UncleError
(
fmt
.
Sprintf
(
"Uncle's parent unknown (%x)"
,
uncle
.
ParentHash
[
0
:
4
]))
}
if
uncleParent
.
Header
()
.
Number
.
Cmp
(
new
(
big
.
Int
)
.
Sub
(
parent
.
Header
()
.
Number
,
big
.
NewInt
(
6
)))
<
0
{
return
UncleError
(
"Uncle too old"
)
}
/*
uncleParent := sm.bc.GetBlock(uncle.ParentHash)
if uncleParent == nil {
return UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4]))
}
if
knownUncles
.
Has
(
string
(
uncle
.
Hash
()))
{
return
UncleError
(
"Uncle in chain
"
)
}
if uncleParent.Number().Cmp(new(big.Int).Sub(parent.Number(), big.NewInt(6))) < 0
{
return UncleError("Uncle too old
")
}
nonces
.
Insert
(
uncle
.
Nonce
)
if knownUncles.Has(string(uncle.Hash())) {
return UncleError("Uncle in chain")
}
*/
r
:=
new
(
big
.
Int
)
r
.
Mul
(
BlockReward
,
big
.
NewInt
(
15
))
.
Div
(
r
,
big
.
NewInt
(
16
))
...
...
core/chain_manager.go
View file @
905b8cc8
...
...
@@ -262,6 +262,28 @@ func (self *ChainManager) GetBlock(hash []byte) *types.Block {
return
&
block
}
func
(
self
*
ChainManager
)
GetUnclesInChain
(
block
*
types
.
Block
,
length
int
)
(
uncles
[]
*
types
.
Header
)
{
for
i
:=
0
;
block
!=
nil
&&
i
<
length
;
i
++
{
uncles
=
append
(
uncles
,
block
.
Uncles
()
...
)
block
=
self
.
GetBlock
(
block
.
ParentHash
())
}
return
}
func
(
self
*
ChainManager
)
GetAncestors
(
block
*
types
.
Block
,
length
int
)
(
blocks
[]
*
types
.
Block
)
{
for
i
:=
0
;
i
<
length
;
i
++
{
block
=
self
.
GetBlock
(
block
.
ParentHash
())
if
block
==
nil
{
break
}
blocks
=
append
(
blocks
,
block
)
}
return
}
func
(
self
*
ChainManager
)
GetBlockByNumber
(
num
uint64
)
*
types
.
Block
{
self
.
mu
.
RLock
()
defer
self
.
mu
.
RUnlock
()
...
...
vm/stack.go
View file @
905b8cc8
...
...
@@ -142,6 +142,10 @@ func (m *Memory) Resize(size uint64) {
}
func
(
m
*
Memory
)
Get
(
offset
,
size
int64
)
[]
byte
{
if
size
==
0
{
return
nil
}
if
len
(
m
.
store
)
>
int
(
offset
)
{
end
:=
int
(
math
.
Min
(
float64
(
len
(
m
.
store
)),
float64
(
offset
+
size
)))
...
...
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