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
d8ac267f
Commit
d8ac267f
authored
Feb 20, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dirty tracking for state objects fixed
parent
982f73fa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
8 deletions
+13
-8
block_processor.go
core/block_processor.go
+2
-5
chain_manager.go
core/chain_manager.go
+1
-1
protocol.go
eth/protocol.go
+1
-1
state_object.go
state/state_object.go
+9
-1
No files found.
core/block_processor.go
View file @
d8ac267f
...
@@ -296,16 +296,13 @@ func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, paren
...
@@ -296,16 +296,13 @@ func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, paren
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
))
uncleAccount
:=
statedb
.
GetAccount
(
uncle
.
Coinbase
)
statedb
.
AddBalance
(
uncle
.
Coinbase
,
r
)
uncleAccount
.
AddAmount
(
r
)
reward
.
Add
(
reward
,
new
(
big
.
Int
)
.
Div
(
BlockReward
,
big
.
NewInt
(
32
)))
reward
.
Add
(
reward
,
new
(
big
.
Int
)
.
Div
(
BlockReward
,
big
.
NewInt
(
32
)))
}
}
// Get the account associated with the coinbase
// Get the account associated with the coinbase
account
:=
statedb
.
GetAccount
(
block
.
Header
()
.
Coinbase
)
statedb
.
AddBalance
(
block
.
Header
()
.
Coinbase
,
reward
)
// Reward amount of ether to the coinbase address
account
.
AddAmount
(
reward
)
return
nil
return
nil
}
}
...
...
core/chain_manager.go
View file @
d8ac267f
...
@@ -397,7 +397,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -397,7 +397,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
if
chain
{
if
chain
{
//self.setTransState(state.New(block.Root(), self.db))
//self.setTransState(state.New(block.Root(), self.db))
self
.
eventMux
.
Post
(
ChainEvent
{
block
,
td
})
//
self.eventMux.Post(ChainEvent{block, td})
}
}
if
split
{
if
split
{
...
...
eth/protocol.go
View file @
d8ac267f
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
)
)
const
(
const
(
ProtocolVersion
=
5
2
ProtocolVersion
=
5
3
NetworkId
=
0
NetworkId
=
0
ProtocolLength
=
uint64
(
8
)
ProtocolLength
=
uint64
(
8
)
ProtocolMaxMsgSize
=
10
*
1024
*
1024
ProtocolMaxMsgSize
=
10
*
1024
*
1024
...
...
state/state_object.go
View file @
d8ac267f
...
@@ -65,7 +65,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
...
@@ -65,7 +65,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
// This to ensure that it has 20 bytes (and not 0 bytes), thus left or right pad doesn't matter.
// This to ensure that it has 20 bytes (and not 0 bytes), thus left or right pad doesn't matter.
address
:=
ethutil
.
Address
(
addr
)
address
:=
ethutil
.
Address
(
addr
)
object
:=
&
StateObject
{
db
:
db
,
address
:
address
,
balance
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)}
object
:=
&
StateObject
{
db
:
db
,
address
:
address
,
balance
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)
,
dirty
:
true
}
object
.
State
=
New
(
nil
,
db
)
//New(trie.New(ethutil.Config.Db, ""))
object
.
State
=
New
(
nil
,
db
)
//New(trie.New(ethutil.Config.Db, ""))
object
.
storage
=
make
(
Storage
)
object
.
storage
=
make
(
Storage
)
object
.
gasPool
=
new
(
big
.
Int
)
object
.
gasPool
=
new
(
big
.
Int
)
...
@@ -118,6 +118,7 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
...
@@ -118,6 +118,7 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
}
}
func
(
self
*
StateObject
)
SetStorage
(
key
*
big
.
Int
,
value
*
ethutil
.
Value
)
{
func
(
self
*
StateObject
)
SetStorage
(
key
*
big
.
Int
,
value
*
ethutil
.
Value
)
{
self
.
SetState
(
key
.
Bytes
(),
value
)
self
.
SetState
(
key
.
Bytes
(),
value
)
self
.
dirty
=
true
}
}
func
(
self
*
StateObject
)
Storage
()
map
[
string
]
*
ethutil
.
Value
{
func
(
self
*
StateObject
)
Storage
()
map
[
string
]
*
ethutil
.
Value
{
...
@@ -142,6 +143,7 @@ func (self *StateObject) GetState(k []byte) *ethutil.Value {
...
@@ -142,6 +143,7 @@ func (self *StateObject) GetState(k []byte) *ethutil.Value {
func
(
self
*
StateObject
)
SetState
(
k
[]
byte
,
value
*
ethutil
.
Value
)
{
func
(
self
*
StateObject
)
SetState
(
k
[]
byte
,
value
*
ethutil
.
Value
)
{
key
:=
ethutil
.
LeftPadBytes
(
k
,
32
)
key
:=
ethutil
.
LeftPadBytes
(
k
,
32
)
self
.
storage
[
string
(
key
)]
=
value
.
Copy
()
self
.
storage
[
string
(
key
)]
=
value
.
Copy
()
self
.
dirty
=
true
}
}
func
(
self
*
StateObject
)
Sync
()
{
func
(
self
*
StateObject
)
Sync
()
{
...
@@ -166,6 +168,7 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
...
@@ -166,6 +168,7 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
func
(
c
*
StateObject
)
AddBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
AddBalance
(
amount
*
big
.
Int
)
{
c
.
SetBalance
(
new
(
big
.
Int
)
.
Add
(
c
.
balance
,
amount
))
c
.
SetBalance
(
new
(
big
.
Int
)
.
Add
(
c
.
balance
,
amount
))
c
.
dirty
=
true
statelogger
.
Debugf
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
balance
,
amount
)
statelogger
.
Debugf
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
balance
,
amount
)
}
}
...
@@ -180,6 +183,7 @@ func (c *StateObject) SubAmount(amount *big.Int) { c.SubBalance(amount) }
...
@@ -180,6 +183,7 @@ func (c *StateObject) SubAmount(amount *big.Int) { c.SubBalance(amount) }
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
c
.
balance
=
amount
c
.
balance
=
amount
c
.
dirty
=
true
}
}
func
(
self
*
StateObject
)
Balance
()
*
big
.
Int
{
return
self
.
balance
}
func
(
self
*
StateObject
)
Balance
()
*
big
.
Int
{
return
self
.
balance
}
...
@@ -198,6 +202,8 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
...
@@ -198,6 +202,8 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
c
.
SubAmount
(
total
)
c
.
SubAmount
(
total
)
c
.
dirty
=
true
return
nil
return
nil
}
}
...
@@ -219,6 +225,8 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
...
@@ -219,6 +225,8 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
self
.
AddAmount
(
rGas
)
self
.
AddAmount
(
rGas
)
self
.
dirty
=
true
return
nil
return
nil
}
}
...
...
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