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
bfb9ed88
Commit
bfb9ed88
authored
Mar 23, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gas validation and clean up of legacy code
parent
ebf4408d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
block_processor.go
core/block_processor.go
+11
-12
No files found.
core/block_processor.go
View file @
bfb9ed88
...
@@ -61,7 +61,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
...
@@ -61,7 +61,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
coinbase
.
SetGasPool
(
block
.
Header
()
.
GasLimit
)
coinbase
.
SetGasPool
(
block
.
Header
()
.
GasLimit
)
// Process the transactions on to parent state
// Process the transactions on to parent state
receipts
,
_
,
_
,
_
,
err
=
sm
.
ApplyTransactions
(
coinbase
,
statedb
,
block
,
block
.
Transactions
(),
transientProcess
)
receipts
,
err
=
sm
.
ApplyTransactions
(
coinbase
,
statedb
,
block
,
block
.
Transactions
(),
transientProcess
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -104,39 +104,38 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
...
@@ -104,39 +104,38 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
return
self
.
bc
return
self
.
bc
}
}
func
(
self
*
BlockProcessor
)
ApplyTransactions
(
coinbase
*
state
.
StateObject
,
statedb
*
state
.
StateDB
,
block
*
types
.
Block
,
txs
types
.
Transactions
,
transientProcess
bool
)
(
types
.
Receipts
,
types
.
Transactions
,
types
.
Transactions
,
types
.
Transactions
,
error
)
{
func
(
self
*
BlockProcessor
)
ApplyTransactions
(
coinbase
*
state
.
StateObject
,
statedb
*
state
.
StateDB
,
block
*
types
.
Block
,
txs
types
.
Transactions
,
transientProcess
bool
)
(
types
.
Receipts
,
error
)
{
var
(
var
(
receipts
types
.
Receipts
receipts
types
.
Receipts
handled
,
unhandled
types
.
Transactions
totalUsedGas
=
big
.
NewInt
(
0
)
erroneous
types
.
Transactions
err
error
totalUsedGas
=
big
.
NewInt
(
0
)
cumulativeSum
=
new
(
big
.
Int
)
err
error
cumulativeSum
=
new
(
big
.
Int
)
)
)
for
_
,
tx
:=
range
txs
{
for
_
,
tx
:=
range
txs
{
receipt
,
txGas
,
err
:=
self
.
ApplyTransaction
(
coinbase
,
statedb
,
block
,
tx
,
totalUsedGas
,
transientProcess
)
receipt
,
txGas
,
err
:=
self
.
ApplyTransaction
(
coinbase
,
statedb
,
block
,
tx
,
totalUsedGas
,
transientProcess
)
if
err
!=
nil
&&
(
IsNonceErr
(
err
)
||
state
.
IsGasLimitErr
(
err
)
||
IsInvalidTxErr
(
err
))
{
if
err
!=
nil
&&
(
IsNonceErr
(
err
)
||
state
.
IsGasLimitErr
(
err
)
||
IsInvalidTxErr
(
err
))
{
return
nil
,
nil
,
nil
,
nil
,
err
return
nil
,
err
}
}
if
err
!=
nil
{
if
err
!=
nil
{
statelogger
.
Infoln
(
"TX err:"
,
err
)
statelogger
.
Infoln
(
"TX err:"
,
err
)
}
}
receipts
=
append
(
receipts
,
receipt
)
receipts
=
append
(
receipts
,
receipt
)
handled
=
append
(
handled
,
tx
)
cumulativeSum
.
Add
(
cumulativeSum
,
new
(
big
.
Int
)
.
Mul
(
txGas
,
tx
.
GasPrice
()))
cumulativeSum
.
Add
(
cumulativeSum
,
new
(
big
.
Int
)
.
Mul
(
txGas
,
tx
.
GasPrice
()))
}
}
block
.
Reward
=
cumulativeSum
block
.
Reward
=
cumulativeSum
block
.
Header
()
.
GasUsed
=
totalUsedGas
if
block
.
GasUsed
()
.
Cmp
(
totalUsedGas
)
!=
0
{
return
nil
,
ValidationError
(
fmt
.
Sprintf
(
"gas used error (%v / %v)"
,
block
.
GasUsed
(),
totalUsedGas
))
}
if
transientProcess
{
if
transientProcess
{
go
self
.
eventMux
.
Post
(
PendingBlockEvent
{
block
,
statedb
.
Logs
()})
go
self
.
eventMux
.
Post
(
PendingBlockEvent
{
block
,
statedb
.
Logs
()})
}
}
return
receipts
,
handled
,
unhandled
,
erroneous
,
err
return
receipts
,
err
}
}
// Process block will attempt to process the given block's transactions and applies them
// Process block will attempt to process the given block's transactions and applies them
...
...
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