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
cbf221f6
Commit
cbf221f6
authored
May 21, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed competing block method
parent
734b2e4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
state_manager.go
ethchain/state_manager.go
+13
-2
miner.go
ethminer/miner.go
+1
-1
peer.go
peer.go
+2
-2
No files found.
ethchain/state_manager.go
View file @
cbf221f6
...
...
@@ -132,8 +132,19 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
}
}
func
(
sm
*
StateManager
)
Process
(
block
*
Block
,
dontReact
bool
)
error
{
if
!
sm
.
bc
.
HasBlock
(
block
.
PrevHash
)
{
return
ParentError
(
block
.
PrevHash
)
}
parent
:=
sm
.
bc
.
GetBlock
(
block
.
PrevHash
)
return
sm
.
ProcessBlock
(
parent
.
State
(),
parent
,
block
,
dontReact
)
}
// Block processing and validating with a given (temporarily) state
func
(
sm
*
StateManager
)
ProcessBlock
(
state
*
State
,
block
*
Block
,
dontReact
bool
)
error
{
func
(
sm
*
StateManager
)
ProcessBlock
(
state
*
State
,
parent
,
block
*
Block
,
dontReact
bool
)
error
{
// Processing a blocks may never happen simultaneously
sm
.
mutex
.
Lock
()
defer
sm
.
mutex
.
Unlock
()
...
...
@@ -186,7 +197,7 @@ func (sm *StateManager) ProcessBlock(state *State, block *Block, dontReact bool)
sm
.
bc
.
Add
(
block
)
sm
.
notifyChanges
(
state
)
ethutil
.
Config
.
Log
.
Infof
(
"[STATE] Added block #%d (%x)
\n
"
,
block
.
BlockInfo
()
.
Number
,
block
.
Hash
())
ethutil
.
Config
.
Log
.
Infof
(
"[STATE] Added block #%d (%x)
\n
"
,
block
.
Number
,
block
.
Hash
())
if
dontReact
==
false
{
sm
.
Ethereum
.
Reactor
()
.
Post
(
"newBlock"
,
block
)
...
...
ethminer/miner.go
View file @
cbf221f6
...
...
@@ -126,7 +126,7 @@ func (miner *Miner) listener() {
// Search the nonce
miner
.
block
.
Nonce
=
miner
.
pow
.
Search
(
miner
.
block
,
miner
.
quitChan
)
if
miner
.
block
.
Nonce
!=
nil
{
err
:=
miner
.
ethereum
.
StateManager
()
.
Process
Block
(
miner
.
ethereum
.
StateManager
()
.
CurrentState
(),
miner
.
block
,
true
)
err
:=
miner
.
ethereum
.
StateManager
()
.
Process
(
miner
.
block
,
true
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
err
)
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
...
...
peer.go
View file @
cbf221f6
...
...
@@ -335,8 +335,8 @@ func (p *Peer) HandleInbound() {
block
=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
i
))
//p.ethereum.StateManager().PrepareDefault(block)
state
:=
p
.
ethereum
.
StateManager
()
.
CurrentState
()
err
=
p
.
ethereum
.
StateManager
()
.
Process
Block
(
state
,
block
,
false
)
//
state := p.ethereum.StateManager().CurrentState()
err
=
p
.
ethereum
.
StateManager
()
.
Process
(
block
,
false
)
if
err
!=
nil
{
if
ethutil
.
Config
.
Debug
{
...
...
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