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
07c3de3f
Commit
07c3de3f
authored
Jun 20, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, miner, xeth: renamed gas methods
* BuyGas => SubGas * RefundGas => AddGas * SetGasPool => SetGasLimit
parent
3deded28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
34 deletions
+10
-34
block_processor.go
core/block_processor.go
+1
-1
chain_makers.go
core/chain_makers.go
+1
-1
state_object.go
core/state/state_object.go
+3
-16
state_transition.go
core/state_transition.go
+2
-13
worker.go
miner/worker.go
+1
-1
xeth.go
xeth/xeth.go
+2
-2
No files found.
core/block_processor.go
View file @
07c3de3f
...
...
@@ -58,7 +58,7 @@ func NewBlockProcessor(db, extra common.Database, pow pow.PoW, chainManager *Cha
func
(
sm
*
BlockProcessor
)
TransitionState
(
statedb
*
state
.
StateDB
,
parent
,
block
*
types
.
Block
,
transientProcess
bool
)
(
receipts
types
.
Receipts
,
err
error
)
{
coinbase
:=
statedb
.
GetOrNewStateObject
(
block
.
Header
()
.
Coinbase
)
coinbase
.
SetGas
Pool
(
block
.
Header
()
.
GasLimit
)
coinbase
.
SetGas
Limit
(
block
.
Header
()
.
GasLimit
)
// Process the transactions on to parent state
receipts
,
err
=
sm
.
ApplyTransactions
(
coinbase
,
statedb
,
block
,
block
.
Transactions
(),
transientProcess
)
...
...
core/chain_makers.go
View file @
07c3de3f
...
...
@@ -79,7 +79,7 @@ func makeBlock(bman *BlockProcessor, parent *types.Block, i int, db common.Datab
block
:=
newBlockFromParent
(
addr
,
parent
)
state
:=
state
.
New
(
block
.
Root
(),
db
)
cbase
:=
state
.
GetOrNewStateObject
(
addr
)
cbase
.
SetGas
Pool
(
CalcGasLimit
(
parent
))
cbase
.
SetGas
Limit
(
CalcGasLimit
(
parent
))
cbase
.
AddBalance
(
BlockReward
)
state
.
Update
()
block
.
SetRoot
(
state
.
Root
())
...
...
core/state/state_object.go
View file @
07c3de3f
...
...
@@ -104,7 +104,6 @@ func NewStateObjectFromBytes(address common.Address, data []byte, db common.Data
}
object
:=
&
StateObject
{
address
:
address
,
db
:
db
}
//object.RlpDecode(data)
object
.
nonce
=
extobject
.
Nonce
object
.
balance
=
extobject
.
Balance
object
.
codeHash
=
extobject
.
CodeHash
...
...
@@ -215,20 +214,8 @@ func (c *StateObject) St() Storage {
// Return the gas back to the origin. Used by the Virtual machine or Closures
func
(
c
*
StateObject
)
ReturnGas
(
gas
,
price
*
big
.
Int
)
{}
func
(
c
*
StateObject
)
ConvertGas
(
gas
,
price
*
big
.
Int
)
error
{
total
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
if
total
.
Cmp
(
c
.
balance
)
>
0
{
return
fmt
.
Errorf
(
"insufficient amount: %v, %v"
,
c
.
balance
,
total
)
}
c
.
SubBalance
(
total
)
c
.
dirty
=
true
return
nil
}
func
(
self
*
StateObject
)
SetGas
Pool
(
gasLimit
*
big
.
Int
)
{
func
(
self
*
StateObject
)
SetGas
Limit
(
gasLimit
*
big
.
Int
)
{
self
.
gasPool
=
new
(
big
.
Int
)
.
Set
(
gasLimit
)
if
glog
.
V
(
logger
.
Core
)
{
...
...
@@ -236,7 +223,7 @@ func (self *StateObject) SetGasPool(gasLimit *big.Int) {
}
}
func
(
self
*
StateObject
)
Buy
Gas
(
gas
,
price
*
big
.
Int
)
error
{
func
(
self
*
StateObject
)
Sub
Gas
(
gas
,
price
*
big
.
Int
)
error
{
if
self
.
gasPool
.
Cmp
(
gas
)
<
0
{
return
GasLimitError
(
self
.
gasPool
,
gas
)
}
...
...
@@ -251,7 +238,7 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
return
nil
}
func
(
self
*
StateObject
)
Refun
dGas
(
gas
,
price
*
big
.
Int
)
{
func
(
self
*
StateObject
)
Ad
dGas
(
gas
,
price
*
big
.
Int
)
{
self
.
gasPool
.
Add
(
self
.
gasPool
,
gas
)
}
...
...
core/state_transition.go
View file @
07c3de3f
...
...
@@ -151,7 +151,7 @@ func (self *StateTransition) BuyGas() error {
}
coinbase
:=
self
.
Coinbase
()
err
=
coinbase
.
Buy
Gas
(
self
.
msg
.
Gas
(),
self
.
msg
.
GasPrice
())
err
=
coinbase
.
Sub
Gas
(
self
.
msg
.
Gas
(),
self
.
msg
.
GasPrice
())
if
err
!=
nil
{
return
err
}
...
...
@@ -245,20 +245,9 @@ func (self *StateTransition) refundGas() {
self
.
gas
.
Add
(
self
.
gas
,
refund
)
self
.
state
.
AddBalance
(
sender
.
Address
(),
refund
.
Mul
(
refund
,
self
.
msg
.
GasPrice
()))
coinbase
.
Refun
dGas
(
self
.
gas
,
self
.
msg
.
GasPrice
())
coinbase
.
Ad
dGas
(
self
.
gas
,
self
.
msg
.
GasPrice
())
}
func
(
self
*
StateTransition
)
gasUsed
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Sub
(
self
.
initialGas
,
self
.
gas
)
}
// Converts an message in to a state object
func
makeContract
(
msg
Message
,
state
*
state
.
StateDB
)
*
state
.
StateObject
{
faddr
,
_
:=
msg
.
From
()
addr
:=
crypto
.
CreateAddress
(
faddr
,
msg
.
Nonce
())
contract
:=
state
.
GetOrNewStateObject
(
addr
)
contract
.
SetInitCode
(
msg
.
Data
())
return
contract
}
miner/worker.go
View file @
07c3de3f
...
...
@@ -319,7 +319,7 @@ func (self *worker) makeCurrent() {
current
.
localMinedBlocks
=
self
.
current
.
localMinedBlocks
}
current
.
coinbase
.
SetGas
Pool
(
core
.
CalcGasLimit
(
parent
))
current
.
coinbase
.
SetGas
Limit
(
core
.
CalcGasLimit
(
parent
))
self
.
current
=
current
}
...
...
xeth/xeth.go
View file @
07c3de3f
...
...
@@ -212,7 +212,7 @@ func (self *XEth) ApplyTestTxs(statedb *state.StateDB, address common.Address, t
block
:=
self
.
backend
.
ChainManager
()
.
NewBlock
(
address
)
coinbase
:=
statedb
.
GetStateObject
(
address
)
coinbase
.
SetGas
Pool
(
big
.
NewInt
(
10000000
))
coinbase
.
SetGas
Limit
(
big
.
NewInt
(
10000000
))
txs
:=
self
.
backend
.
TxPool
()
.
GetQueuedTransactions
()
for
i
:=
0
;
i
<
len
(
txs
);
i
++
{
...
...
@@ -827,7 +827,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
}
from
.
SetBalance
(
common
.
MaxBig
)
from
.
SetGas
Pool
(
self
.
backend
.
ChainManager
()
.
GasLimit
())
from
.
SetGas
Limit
(
self
.
backend
.
ChainManager
()
.
GasLimit
())
msg
:=
callmsg
{
from
:
from
,
to
:
common
.
HexToAddress
(
toStr
),
...
...
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