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
095d5baa
Commit
095d5baa
authored
Mar 17, 2014
by
Maran
Browse files
Options
Browse Files
Download
Plain Diff
Merge conflicts
parents
8ea7e21f
b15a4985
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
27 deletions
+29
-27
state_manager.go
ethchain/state_manager.go
+25
-24
transaction_pool.go
ethchain/transaction_pool.go
+2
-2
peer.go
peer.go
+2
-1
No files found.
ethchain/state_manager.go
View file @
095d5baa
...
...
@@ -64,6 +64,7 @@ func NewStateManager(ethereum EthManager) *StateManager {
addrStateStore
:
NewAddrStateStore
(),
bc
:
ethereum
.
BlockChain
(),
}
sm
.
procState
=
ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
return
sm
}
...
...
@@ -78,8 +79,8 @@ func (sm *StateManager) MiningState() *State {
// Watches any given address and puts it in the address state store
func
(
sm
*
StateManager
)
WatchAddr
(
addr
[]
byte
)
*
AccountState
{
//
FIXME account := sm.procS
tate.GetAccount(addr)
account
:=
sm
.
bc
.
CurrentBlock
.
s
tate
.
GetAccount
(
addr
)
//
XXX account := sm.bc.CurrentBlock.s
tate.GetAccount(addr)
account
:=
sm
.
procS
tate
.
GetAccount
(
addr
)
return
sm
.
addrStateStore
.
Add
(
addr
,
account
)
}
...
...
@@ -112,16 +113,16 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
for
_
,
tx
:=
range
txs
{
// If there's no recipient, it's a contract
if
tx
.
IsContract
()
{
//FIXME
sm.MakeContract(tx)
block
.
MakeContract
(
tx
)
sm
.
MakeContract
(
tx
)
//XXX
block.MakeContract(tx)
}
else
{
//FIXME if contract :=
procState.GetContract(tx.Recipient); contract != nil {
if
contract
:=
block
.
state
.
GetContract
(
tx
.
Recipient
);
contract
!=
nil
{
if
contract
:=
sm
.
procState
.
GetContract
(
tx
.
Recipient
);
contract
!=
nil
{
//XXX
if contract := block.state.GetContract(tx.Recipient); contract != nil {
sm
.
ProcessContract
(
contract
,
tx
,
block
)
}
else
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[
smGR
]"
,
err
)
ethutil
.
Config
.
Log
.
Infoln
(
"[
STATE
]"
,
err
)
}
}
}
...
...
@@ -177,21 +178,21 @@ func (sm *StateManager) ProcessBlock(block *Block) error {
// I'm not sure, but I don't know if there should be thrown
// any errors at this time.
if
err
:=
sm
.
AccumelateRewards
(
sm
.
bc
.
CurrentBlock
,
block
);
err
!=
nil
{
if
err
:=
sm
.
AccumelateRewards
(
block
);
err
!=
nil
{
return
err
}
// if !sm.compState.Cmp(sm.procState)
if
!
block
.
state
.
Cmp
(
sm
.
bc
.
CurrentBlock
.
s
tate
)
{
return
fmt
.
Errorf
(
"Invalid merkle root. Expected %x, got %x"
,
block
.
State
()
.
trie
.
Root
,
sm
.
bc
.
CurrentBlock
.
State
()
.
trie
.
Root
)
//FIXME
return fmt.Errorf("Invalid merkle root. Expected %x, got %x", sm.compState.trie.Root, sm.procState.trie.Root)
if
!
sm
.
compState
.
Cmp
(
sm
.
procS
tate
)
{
//XXX
return fmt.Errorf("Invalid merkle root. Expected %x, got %x", block.State().trie.Root, sm.bc.CurrentBlock.State().trie.Root)
return
fmt
.
Errorf
(
"Invalid merkle root. Expected %x, got %x"
,
sm
.
compState
.
trie
.
Root
,
sm
.
procState
.
trie
.
Root
)
}
// Calculate the new total difficulty and sync back to the db
if
sm
.
CalculateTD
(
block
)
{
// Sync the current block's state to the database and cancelling out the deferred Undo
sm
.
bc
.
CurrentBlock
.
Sync
()
//FIXME
sm.procState.Sync()
//XXX
sm.bc.CurrentBlock.Sync()
sm
.
procState
.
Sync
()
// Broadcast the valid block back to the wire
//sm.Ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
...
...
@@ -205,7 +206,7 @@ func (sm *StateManager) ProcessBlock(block *Block) error {
sm
.
SecondaryBlockProcessor
.
ProcessBlock
(
block
)
}
ethutil
.
Config
.
Log
.
Infof
(
"[
smGR
] Added block #%d (%x)
\n
"
,
block
.
BlockInfo
()
.
Number
,
block
.
Hash
())
ethutil
.
Config
.
Log
.
Infof
(
"[
STATE
] Added block #%d (%x)
\n
"
,
block
.
BlockInfo
()
.
Number
,
block
.
Hash
())
sm
.
Ethereum
.
Reactor
()
.
Post
(
"newBlock"
,
block
)
}
else
{
fmt
.
Println
(
"total diff failed"
)
...
...
@@ -283,22 +284,22 @@ func CalculateUncleReward(block *Block) *big.Int {
return
UncleReward
}
func
(
sm
*
StateManager
)
AccumelateRewards
(
processor
*
Block
,
block
*
Block
)
error
{
func
(
sm
*
StateManager
)
AccumelateRewards
(
block
*
Block
)
error
{
// Get the coinbase rlp data
addr
:=
processor
.
state
.
GetAccount
(
block
.
Coinbase
)
//FIXME addr := proc
.GetAccount(block.Coinbase)
//XXX
addr := processor.state.GetAccount(block.Coinbase)
addr
:=
sm
.
procState
.
GetAccount
(
block
.
Coinbase
)
// Reward amount of ether to the coinbase address
addr
.
AddFee
(
CalculateBlockReward
(
block
,
len
(
block
.
Uncles
)))
processor
.
state
.
UpdateAccount
(
block
.
Coinbase
,
addr
)
//FIXME proc
.UpdateAccount(block.Coinbase, addr)
//XXX
processor.state.UpdateAccount(block.Coinbase, addr)
sm
.
procState
.
UpdateAccount
(
block
.
Coinbase
,
addr
)
for
_
,
uncle
:=
range
block
.
Uncles
{
uncleAddr
:=
processor
.
s
tate
.
GetAccount
(
uncle
.
Coinbase
)
uncleAddr
:=
sm
.
procS
tate
.
GetAccount
(
uncle
.
Coinbase
)
uncleAddr
.
AddFee
(
CalculateUncleReward
(
uncle
))
processor
.
state
.
UpdateAccount
(
uncle
.
Coinbase
,
uncleAddr
)
//FIXME proc
.UpdateAccount(uncle.Coinbase, uncleAddr)
//
processor.state.UpdateAccount(uncle.Coinbase, uncleAddr)
sm
.
procState
.
UpdateAccount
(
uncle
.
Coinbase
,
uncleAddr
)
}
return
nil
...
...
@@ -319,8 +320,8 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
*/
vm
:=
&
Vm
{}
//vm.Process(contract,
sm.procS
tate, RuntimeVars{
vm
.
Process
(
contract
,
block
.
s
tate
,
RuntimeVars
{
//vm.Process(contract,
block.s
tate, RuntimeVars{
vm
.
Process
(
contract
,
sm
.
procS
tate
,
RuntimeVars
{
address
:
tx
.
Hash
()[
12
:
],
blockNumber
:
block
.
BlockInfo
()
.
Number
,
sender
:
tx
.
Sender
(),
...
...
ethchain/transaction_pool.go
View file @
095d5baa
...
...
@@ -235,11 +235,11 @@ func (pool *TxPool) Start() {
}
func
(
pool
*
TxPool
)
Stop
()
{
log
.
Println
(
"[TXP] Stopping..."
)
close
(
pool
.
quit
)
pool
.
Flush
()
log
.
Println
(
"[TXP] Stopped"
)
}
func
(
pool
*
TxPool
)
Subscribe
(
channel
chan
TxMsg
)
{
...
...
peer.go
View file @
095d5baa
...
...
@@ -293,7 +293,8 @@ func (p *Peer) HandleInbound() {
var
err
error
for
i
:=
msg
.
Data
.
Len
()
-
1
;
i
>=
0
;
i
--
{
block
=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
i
))
// FIXME p.ethereum.BlockManager.DefaultPrepare(block)
p
.
ethereum
.
StateManager
()
.
PrepareDefault
(
block
)
err
=
p
.
ethereum
.
StateManager
()
.
ProcessBlock
(
block
)
if
err
!=
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