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