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
8730dfdc
Commit
8730dfdc
authored
May 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed how changes are being applied to states
parent
88686cbe
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
98 deletions
+82
-98
block_chain.go
ethchain/block_chain.go
+2
-2
block_chain_test.go
ethchain/block_chain_test.go
+14
-3
state_manager.go
ethchain/state_manager.go
+50
-59
transaction_pool.go
ethchain/transaction_pool.go
+2
-1
vm_test.go
ethchain/vm_test.go
+1
-1
ethereum.go
ethereum.go
+1
-1
miner.go
ethminer/miner.go
+6
-18
pub.go
ethpub/pub.go
+1
-1
config.go
ethutil/config.go
+2
-10
peer.go
peer.go
+3
-2
No files found.
ethchain/block_chain.go
View file @
8730dfdc
...
...
@@ -280,7 +280,7 @@ func (bc *BlockChain) setLastBlock() {
bc
.
LastBlockHash
=
block
.
Hash
()
bc
.
LastBlockNumber
=
info
.
Number
log
.
Print
f
(
"[CHAIN] Last known block height #%d
\n
"
,
bc
.
LastBlockNumber
)
ethutil
.
Config
.
Log
.
Info
f
(
"[CHAIN] Last known block height #%d
\n
"
,
bc
.
LastBlockNumber
)
}
else
{
AddTestNetFunds
(
bc
.
genesisBlock
)
...
...
@@ -295,7 +295,7 @@ func (bc *BlockChain) setLastBlock() {
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
bc
.
TD
=
ethutil
.
BigD
(
ethutil
.
Config
.
Db
.
LastKnownTD
())
log
.
Print
f
(
"Last block: %x
\n
"
,
bc
.
CurrentBlock
.
Hash
())
ethutil
.
Config
.
Log
.
Info
f
(
"Last block: %x
\n
"
,
bc
.
CurrentBlock
.
Hash
())
}
func
(
bc
*
BlockChain
)
SetTotalDifficulty
(
td
*
big
.
Int
)
{
...
...
ethchain/block_chain_test.go
View file @
8730dfdc
...
...
@@ -18,6 +18,18 @@ type TestManager struct {
Blocks
[]
*
Block
}
func
(
s
*
TestManager
)
IsListening
()
bool
{
return
false
}
func
(
s
*
TestManager
)
IsMining
()
bool
{
return
false
}
func
(
s
*
TestManager
)
PeerCount
()
int
{
return
0
}
func
(
s
*
TestManager
)
BlockChain
()
*
BlockChain
{
return
s
.
blockChain
}
...
...
@@ -38,7 +50,7 @@ func (tm *TestManager) Broadcast(msgType ethwire.MsgType, data []interface{}) {
}
func
NewTestManager
()
*
TestManager
{
ethutil
.
ReadConfig
(
".ethtest"
)
ethutil
.
ReadConfig
(
".ethtest"
,
ethutil
.
LogStd
)
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
...
...
@@ -62,8 +74,7 @@ func NewTestManager() *TestManager {
func
(
tm
*
TestManager
)
AddFakeBlock
(
blk
[]
byte
)
error
{
block
:=
NewBlockFromBytes
(
blk
)
tm
.
Blocks
=
append
(
tm
.
Blocks
,
block
)
tm
.
StateManager
()
.
PrepareDefault
(
block
)
err
:=
tm
.
StateManager
()
.
ProcessBlock
(
block
,
false
)
err
:=
tm
.
StateManager
()
.
ProcessBlock
(
tm
.
StateManager
()
.
CurrentState
(),
block
,
false
)
return
err
}
func
(
tm
*
TestManager
)
CreateChain1
()
error
{
...
...
ethchain/state_manager.go
View file @
8730dfdc
...
...
@@ -39,20 +39,13 @@ type StateManager struct {
// The ethereum manager interface
Ethereum
EthManager
// The managed states
// Processor state. Anything processed will be applied to this
// state
procState
*
State
// Comparative state it used for comparing and validating end
// results
compState
*
State
// Transiently state. The trans state isn't ever saved, validated and
// it could be used for setting account nonces without effecting
// the main states.
transState
*
State
// Manifest for keeping changes regarding state objects. See `notify`
// XXX Should we move the manifest to the State object. Benefit:
// * All states can keep their own local changes
//manifest *Manifest
// Mining state. The mining state is used purely and solely by the mining
// operation.
miningState
*
State
}
func
NewStateManager
(
ethereum
EthManager
)
*
StateManager
{
...
...
@@ -62,30 +55,39 @@ func NewStateManager(ethereum EthManager) *StateManager {
Pow
:
&
EasyPow
{},
Ethereum
:
ethereum
,
bc
:
ethereum
.
BlockChain
(),
//manifest: NewManifest(),
}
sm
.
procState
=
ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
sm
.
transState
=
sm
.
procState
.
Copy
()
sm
.
transState
=
ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
.
Copy
()
sm
.
miningState
=
ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
.
Copy
()
return
sm
}
func
(
sm
*
StateManager
)
Proc
State
()
*
State
{
return
sm
.
procState
func
(
sm
*
StateManager
)
Current
State
()
*
State
{
return
sm
.
Ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
}
func
(
sm
*
StateManager
)
TransState
()
*
State
{
return
sm
.
transState
}
func
(
sm
*
StateManager
)
MiningState
()
*
State
{
return
sm
.
miningState
}
func
(
sm
*
StateManager
)
NewMiningState
()
*
State
{
sm
.
miningState
=
sm
.
Ethereum
.
BlockChain
()
.
CurrentBlock
.
State
()
.
Copy
()
return
sm
.
miningState
}
func
(
sm
*
StateManager
)
BlockChain
()
*
BlockChain
{
return
sm
.
bc
}
func
(
sm
*
StateManager
)
MakeContract
(
tx
*
Transaction
)
*
StateObject
{
contract
:=
MakeContract
(
tx
,
s
m
.
procS
tate
)
func
(
sm
*
StateManager
)
MakeContract
(
state
*
State
,
tx
*
Transaction
)
*
StateObject
{
contract
:=
MakeContract
(
tx
,
state
)
if
contract
!=
nil
{
s
m
.
procS
tate
.
states
[
string
(
tx
.
Hash
()[
12
:
])]
=
contract
.
state
state
.
states
[
string
(
tx
.
Hash
()[
12
:
])]
=
contract
.
state
return
contract
}
...
...
@@ -95,7 +97,7 @@ func (sm *StateManager) MakeContract(tx *Transaction) *StateObject {
// Apply transactions uses the transaction passed to it and applies them onto
// the current processing state.
func
(
sm
*
StateManager
)
ApplyTransactions
(
block
*
Block
,
txs
[]
*
Transaction
)
{
func
(
sm
*
StateManager
)
ApplyTransactions
(
state
*
State
,
block
*
Block
,
txs
[]
*
Transaction
)
{
// Process each transaction/contract
for
_
,
tx
:=
range
txs
{
// If there's no recipient, it's a contract
...
...
@@ -104,9 +106,9 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
if
tx
.
IsContract
()
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
false
)
if
err
==
nil
{
contract
:=
sm
.
MakeContract
(
tx
)
contract
:=
sm
.
MakeContract
(
state
,
tx
)
if
contract
!=
nil
{
sm
.
EvalScript
(
contract
.
Init
(),
contract
,
tx
,
block
)
sm
.
EvalScript
(
state
,
contract
.
Init
(),
contract
,
tx
,
block
)
}
else
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] Unable to create contract"
)
}
...
...
@@ -115,9 +117,9 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
}
}
else
{
err
:=
sm
.
Ethereum
.
TxPool
()
.
ProcessTransaction
(
tx
,
block
,
false
)
contract
:=
s
m
.
procS
tate
.
GetContract
(
tx
.
Recipient
)
contract
:=
state
.
GetContract
(
tx
.
Recipient
)
if
err
==
nil
&&
len
(
contract
.
Script
())
>
0
{
sm
.
EvalScript
(
contract
.
Script
(),
contract
,
tx
,
block
)
sm
.
EvalScript
(
state
,
contract
.
Script
(),
contract
,
tx
,
block
)
}
else
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Infoln
(
"[STATE] process:"
,
err
)
}
...
...
@@ -125,20 +127,8 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
}
}
// The prepare function, prepares the state manager for the next
// "ProcessBlock" action.
func
(
sm
*
StateManager
)
Prepare
(
processor
*
State
,
comparative
*
State
)
{
sm
.
compState
=
comparative
sm
.
procState
=
processor
}
// Default prepare function
func
(
sm
*
StateManager
)
PrepareDefault
(
block
*
Block
)
{
sm
.
Prepare
(
sm
.
BlockChain
()
.
CurrentBlock
.
State
(),
block
.
State
())
}
// Block processing and validating with a given (temporarily) state
func
(
sm
*
StateManager
)
ProcessBlock
(
block
*
Block
,
dontReact
bool
)
error
{
func
(
sm
*
StateManager
)
ProcessBlock
(
state
*
State
,
block
*
Block
,
dontReact
bool
)
error
{
// Processing a blocks may never happen simultaneously
sm
.
mutex
.
Lock
()
defer
sm
.
mutex
.
Unlock
()
...
...
@@ -153,7 +143,7 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
// we don't want to undo but since undo only happens on dirty
// nodes this won't happen because Commit would have been called
// before that.
defer
s
m
.
bc
.
CurrentBlock
.
Undo
()
defer
s
tate
.
Reset
()
// Check if we have the parent hash, if it isn't known we discard it
// Reasons might be catching up or simply an invalid block
...
...
@@ -162,7 +152,7 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
}
// Process the transactions on to current block
sm
.
ApplyTransactions
(
sm
.
bc
.
CurrentBlock
,
block
.
Transactions
())
sm
.
ApplyTransactions
(
s
tate
,
s
m
.
bc
.
CurrentBlock
,
block
.
Transactions
())
// Block validation
if
err
:=
sm
.
ValidateBlock
(
block
);
err
!=
nil
{
...
...
@@ -172,19 +162,20 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
// I'm not sure, but I don't know if there should be thrown
// any errors at this time.
if
err
:=
sm
.
AccumelateRewards
(
block
);
err
!=
nil
{
if
err
:=
sm
.
AccumelateRewards
(
state
,
block
);
err
!=
nil
{
fmt
.
Println
(
"[SM] Error accumulating reward"
,
err
)
return
err
}
if
!
sm
.
compState
.
Cmp
(
sm
.
procState
)
{
return
fmt
.
Errorf
(
"Invalid merkle root. Expected %x, got %x"
,
sm
.
compState
.
trie
.
Root
,
sm
.
procState
.
trie
.
Root
)
//if !sm.compState.Cmp(state) {
if
!
block
.
State
()
.
Cmp
(
state
)
{
return
fmt
.
Errorf
(
"Invalid merkle root. Expected %x, got %x"
,
block
.
State
()
.
trie
.
Root
,
state
.
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
s
m
.
procS
tate
.
Sync
()
state
.
Sync
()
// Add the block to the chain
sm
.
bc
.
Add
(
block
)
...
...
@@ -193,14 +184,14 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
if
dontReact
==
false
{
sm
.
Ethereum
.
Reactor
()
.
Post
(
"newBlock"
,
block
)
s
m
.
procS
tate
.
manifest
.
Reset
()
state
.
manifest
.
Reset
()
}
sm
.
notifyChanges
()
sm
.
notifyChanges
(
state
)
sm
.
Ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
block
.
Value
()
.
Val
})
sm
.
Ethereum
.
TxPool
()
.
RemoveInvalid
(
s
m
.
procS
tate
)
sm
.
Ethereum
.
TxPool
()
.
RemoveInvalid
(
state
)
}
else
{
fmt
.
Println
(
"total diff failed"
)
}
...
...
@@ -276,21 +267,21 @@ func CalculateUncleReward(block *Block) *big.Int {
return
UncleReward
}
func
(
sm
*
StateManager
)
AccumelateRewards
(
block
*
Block
)
error
{
func
(
sm
*
StateManager
)
AccumelateRewards
(
state
*
State
,
block
*
Block
)
error
{
// Get the account associated with the coinbase
account
:=
s
m
.
procS
tate
.
GetAccount
(
block
.
Coinbase
)
account
:=
state
.
GetAccount
(
block
.
Coinbase
)
// Reward amount of ether to the coinbase address
account
.
AddAmount
(
CalculateBlockReward
(
block
,
len
(
block
.
Uncles
)))
addr
:=
make
([]
byte
,
len
(
block
.
Coinbase
))
copy
(
addr
,
block
.
Coinbase
)
s
m
.
procS
tate
.
UpdateStateObject
(
account
)
state
.
UpdateStateObject
(
account
)
for
_
,
uncle
:=
range
block
.
Uncles
{
uncleAccount
:=
s
m
.
procS
tate
.
GetAccount
(
uncle
.
Coinbase
)
uncleAccount
:=
state
.
GetAccount
(
uncle
.
Coinbase
)
uncleAccount
.
AddAmount
(
CalculateUncleReward
(
uncle
))
s
m
.
procS
tate
.
UpdateStateObject
(
uncleAccount
)
state
.
UpdateStateObject
(
uncleAccount
)
}
return
nil
...
...
@@ -300,8 +291,8 @@ func (sm *StateManager) Stop() {
sm
.
bc
.
Stop
()
}
func
(
sm
*
StateManager
)
EvalScript
(
script
[]
byte
,
object
*
StateObject
,
tx
*
Transaction
,
block
*
Block
)
{
account
:=
s
m
.
procS
tate
.
GetAccount
(
tx
.
Sender
())
func
(
sm
*
StateManager
)
EvalScript
(
s
tate
*
State
,
s
cript
[]
byte
,
object
*
StateObject
,
tx
*
Transaction
,
block
*
Block
)
{
account
:=
state
.
GetAccount
(
tx
.
Sender
())
err
:=
account
.
ConvertGas
(
tx
.
Gas
,
tx
.
GasPrice
)
if
err
!=
nil
{
...
...
@@ -309,8 +300,8 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
return
}
closure
:=
NewClosure
(
account
,
object
,
script
,
s
m
.
procS
tate
,
tx
.
Gas
,
tx
.
GasPrice
)
vm
:=
NewVm
(
s
m
.
procS
tate
,
sm
,
RuntimeVars
{
closure
:=
NewClosure
(
account
,
object
,
script
,
state
,
tx
.
Gas
,
tx
.
GasPrice
)
vm
:=
NewVm
(
state
,
sm
,
RuntimeVars
{
Origin
:
account
.
Address
(),
BlockNumber
:
block
.
BlockInfo
()
.
Number
,
PrevHash
:
block
.
PrevHash
,
...
...
@@ -323,16 +314,16 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
closure
.
Call
(
vm
,
tx
.
Data
,
nil
)
// Update the account (refunds)
s
m
.
procS
tate
.
UpdateStateObject
(
account
)
s
m
.
procS
tate
.
UpdateStateObject
(
object
)
state
.
UpdateStateObject
(
account
)
state
.
UpdateStateObject
(
object
)
}
func
(
sm
*
StateManager
)
notifyChanges
()
{
for
addr
,
stateObject
:=
range
s
m
.
procS
tate
.
manifest
.
objectChanges
{
func
(
sm
*
StateManager
)
notifyChanges
(
state
*
State
)
{
for
addr
,
stateObject
:=
range
state
.
manifest
.
objectChanges
{
sm
.
Ethereum
.
Reactor
()
.
Post
(
"object:"
+
addr
,
stateObject
)
}
for
stateObjectAddr
,
mappedObjects
:=
range
s
m
.
procS
tate
.
manifest
.
storageChanges
{
for
stateObjectAddr
,
mappedObjects
:=
range
state
.
manifest
.
storageChanges
{
for
addr
,
value
:=
range
mappedObjects
{
sm
.
Ethereum
.
Reactor
()
.
Post
(
"storage:"
+
stateObjectAddr
+
":"
+
addr
,
&
StorageState
{[]
byte
(
stateObjectAddr
),
[]
byte
(
addr
),
value
})
}
...
...
ethchain/transaction_pool.go
View file @
8730dfdc
...
...
@@ -149,7 +149,8 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
}
// Get the sender
sender
:=
pool
.
Ethereum
.
StateManager
()
.
procState
.
GetAccount
(
tx
.
Sender
())
//sender := pool.Ethereum.StateManager().procState.GetAccount(tx.Sender())
sender
:=
pool
.
Ethereum
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
totAmount
:=
new
(
big
.
Int
)
.
Add
(
tx
.
Value
,
new
(
big
.
Int
)
.
Mul
(
TxFee
,
TxFeeRat
))
// Make sure there's enough in the sender's account. Having insufficient
...
...
ethchain/vm_test.go
View file @
8730dfdc
...
...
@@ -12,7 +12,7 @@ import (
)
func
TestRun4
(
t
*
testing
.
T
)
{
ethutil
.
ReadConfig
(
""
)
ethutil
.
ReadConfig
(
""
,
ethutil
.
LogStd
)
db
,
_
:=
ethdb
.
NewMemDatabase
()
state
:=
NewState
(
ethutil
.
NewTrie
(
db
,
""
))
...
...
ethereum.go
View file @
8730dfdc
...
...
@@ -235,7 +235,7 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
s
.
peers
.
PushBack
(
peer
)
log
.
Print
f
(
"[SERV] Adding peer %d / %d
\n
"
,
s
.
peers
.
Len
(),
s
.
MaxPeers
)
ethutil
.
Config
.
Log
.
Info
f
(
"[SERV] Adding peer %d / %d
\n
"
,
s
.
peers
.
Len
(),
s
.
MaxPeers
)
}
return
nil
...
...
ethminer/miner.go
View file @
8730dfdc
...
...
@@ -53,8 +53,8 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
}
func
(
miner
*
Miner
)
Start
()
{
// Prepare inital block
miner
.
ethereum
.
StateManager
()
.
Prepare
(
miner
.
block
.
State
(),
miner
.
block
.
State
())
go
func
()
{
miner
.
listener
()
}
()
//
miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
go
miner
.
listener
()
}
func
(
miner
*
Miner
)
listener
()
{
for
{
...
...
@@ -88,7 +88,7 @@ func (miner *Miner) listener() {
if
bytes
.
Compare
(
block
.
PrevHash
,
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
log
.
Println
(
"[MINER] Adding uncle block"
)
miner
.
uncles
=
append
(
miner
.
uncles
,
block
)
miner
.
ethereum
.
StateManager
()
.
Prepare
(
miner
.
block
.
State
(),
miner
.
block
.
State
())
//
miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
}
}
}
...
...
@@ -119,31 +119,19 @@ func (miner *Miner) listener() {
miner
.
block
.
SetUncles
(
miner
.
uncles
)
}
// FIXME @ maranh, first block doesn't need this. Everything after the first block does.
// Please check and fix
miner
.
ethereum
.
StateManager
()
.
Prepare
(
miner
.
block
.
State
(),
miner
.
block
.
State
())
// Apply all transactions to the block
miner
.
ethereum
.
StateManager
()
.
ApplyTransactions
(
miner
.
block
,
miner
.
block
.
Transactions
())
miner
.
ethereum
.
StateManager
()
.
AccumelateRewards
(
miner
.
block
)
miner
.
ethereum
.
StateManager
()
.
ApplyTransactions
(
miner
.
block
.
State
(),
miner
.
block
,
miner
.
block
.
Transactions
())
miner
.
ethereum
.
StateManager
()
.
AccumelateRewards
(
miner
.
block
.
State
(),
miner
.
block
)
// Search the nonce
//log.Println("[MINER] Initialision complete, starting mining")
miner
.
block
.
Nonce
=
miner
.
pow
.
Search
(
miner
.
block
,
miner
.
quitChan
)
if
miner
.
block
.
Nonce
!=
nil
{
miner
.
ethereum
.
StateManager
()
.
PrepareDefault
(
miner
.
block
)
err
:=
miner
.
ethereum
.
StateManager
()
.
ProcessBlock
(
miner
.
block
,
true
)
err
:=
miner
.
ethereum
.
StateManager
()
.
ProcessBlock
(
miner
.
ethereum
.
StateManager
()
.
CurrentState
(),
miner
.
block
,
true
)
if
err
!=
nil
{
log
.
Println
(
err
)
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
}
else
{
/*
// XXX @maranh This is already done in the state manager, why a 2nd time?
if !miner.ethereum.StateManager().Pow.Verify(miner.block.HashNoNonce(), miner.block.Difficulty, miner.block.Nonce) {
log.Printf("Second stage verification error: Block's nonce is invalid (= %v)\n", ethutil.Hex(miner.block.Nonce))
}
*/
miner
.
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
miner
.
block
.
Value
()
.
Val
})
log
.
Printf
(
"[MINER] 🔨 Mined block %x
\n
"
,
miner
.
block
.
Hash
())
...
...
ethpub/pub.go
View file @
8730dfdc
...
...
@@ -45,7 +45,7 @@ func (lib *PEthereum) GetKey() *PKey {
}
func
(
lib
*
PEthereum
)
GetStateObject
(
address
string
)
*
PStateObject
{
stateObject
:=
lib
.
stateManager
.
Proc
State
()
.
GetContract
(
ethutil
.
FromHex
(
address
))
stateObject
:=
lib
.
stateManager
.
Current
State
()
.
GetContract
(
ethutil
.
FromHex
(
address
))
if
stateObject
!=
nil
{
return
NewPStateObject
(
stateObject
)
}
...
...
ethutil/config.go
View file @
8730dfdc
...
...
@@ -9,14 +9,6 @@ import (
"runtime"
)
// Log types available
type
LogType
byte
const
(
LogTypeStdIn
=
1
LogTypeFile
=
2
)
// Config struct
type
config
struct
{
Db
Database
...
...
@@ -34,7 +26,7 @@ var Config *config
// Read config
//
// Initialize the global Config variable with default settings
func
ReadConfig
(
base
string
)
*
config
{
func
ReadConfig
(
base
string
,
logTypes
LoggerType
)
*
config
{
if
Config
==
nil
{
usr
,
_
:=
user
.
Current
()
path
:=
path
.
Join
(
usr
.
HomeDir
,
base
)
...
...
@@ -51,7 +43,7 @@ func ReadConfig(base string) *config {
}
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC6"
}
Config
.
Log
=
NewLogger
(
LogFile
|
LogStd
,
LogLevelDebug
)
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
Config
.
SetClientString
(
"/Ethereum(G)"
)
}
...
...
peer.go
View file @
8730dfdc
...
...
@@ -331,8 +331,9 @@ func (p *Peer) HandleInbound() {
for
i
:=
msg
.
Data
.
Len
()
-
1
;
i
>=
0
;
i
--
{
block
=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
i
))
p
.
ethereum
.
StateManager
()
.
PrepareDefault
(
block
)
err
=
p
.
ethereum
.
StateManager
()
.
ProcessBlock
(
block
,
false
)
//p.ethereum.StateManager().PrepareDefault(block)
state
:=
p
.
ethereum
.
StateManager
()
.
CurrentState
()
err
=
p
.
ethereum
.
StateManager
()
.
ProcessBlock
(
state
,
block
,
false
)
if
err
!=
nil
{
if
ethutil
.
Config
.
Debug
{
...
...
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