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
c8d0f8ad
Commit
c8d0f8ad
authored
Nov 28, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed refund
parent
6ba83280
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
block_manager.go
chain/block_manager.go
+4
-3
miner.go
miner/miner.go
+1
-1
state.go
state/state.go
+16
-13
No files found.
chain/block_manager.go
View file @
c8d0f8ad
...
...
@@ -154,10 +154,11 @@ done:
}
}
txGas
.
Sub
(
txGas
,
st
.
gas
)
// Update the state with pending changes
state
.
Update
()
state
.
Update
(
txGas
)
txGas
.
Sub
(
txGas
,
st
.
gas
)
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
nil
/*bloom*/
,
state
.
Logs
()}
receipt
.
Bloom
=
CreateBloom
(
Receipts
{
receipt
})
...
...
@@ -245,7 +246,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
return
}
state
.
Update
()
state
.
Update
(
nil
)
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
Errorf
(
"invalid merkle root. received=%x got=%x"
,
block
.
Root
(),
state
.
Root
())
...
...
miner/miner.go
View file @
c8d0f8ad
...
...
@@ -203,7 +203,7 @@ func (self *Miner) mine() {
// Accumulate the rewards included for this block
blockManager
.
AccumelateRewards
(
block
.
State
(),
block
,
parent
)
block
.
State
()
.
Update
()
block
.
State
()
.
Update
(
nil
)
minerlogger
.
Infof
(
"Mining on block. Includes %v transactions"
,
len
(
transactions
))
...
...
state/state.go
View file @
c8d0f8ad
...
...
@@ -23,14 +23,14 @@ type State struct {
manifest
*
Manifest
refund
map
[
string
]
*
big
.
Int
refund
map
[
string
]
[]
refund
logs
Logs
}
// Create a new state from a given trie
func
New
(
trie
*
trie
.
Trie
)
*
State
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
*
big
.
Int
)}
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
[]
refund
)}
}
func
(
self
*
State
)
EmptyLogs
()
{
...
...
@@ -55,14 +55,12 @@ func (self *State) GetBalance(addr []byte) *big.Int {
return
ethutil
.
Big0
}
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
amount
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
if
self
.
refund
[
string
(
addr
)]
==
nil
{
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
type
refund
struct
{
gas
,
price
*
big
.
Int
}
self
.
refund
[
string
(
addr
)]
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
refund
{
gas
,
price
})
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
...
...
@@ -276,15 +274,20 @@ func (s *State) Sync() {
func
(
self
*
State
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
self
.
refund
=
make
(
map
[
string
]
[]
refund
)
}
func
(
self
*
State
)
Update
()
{
func
(
self
*
State
)
Update
(
gasUsed
*
big
.
Int
)
{
var
deleted
bool
// Refund any gas that's left
for
addr
,
amount
:=
range
self
.
refund
{
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
amount
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
gasUsed
,
ethutil
.
Big2
)
for
addr
,
refs
:=
range
self
.
refund
{
for
_
,
ref
:=
range
refs
{
refund
:=
ethutil
.
BigMin
(
uhalf
,
ref
.
gas
)
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
refund
.
Mul
(
refund
,
ref
.
price
))
}
}
for
_
,
stateObject
:=
range
self
.
stateObjects
{
...
...
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