aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 7444d5180..312ba3084 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -3,7 +3,7 @@ package ethchain
import (
"bytes"
"container/list"
- "fmt"
+ "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"math/big"
@@ -11,6 +11,8 @@ import (
"time"
)
+var statelogger = ethlog.NewLogger("STATE")
+
type BlockProcessor interface {
ProcessBlock(block *Block)
}
@@ -120,7 +122,7 @@ done:
break done
default:
- ethutil.Config.Log.Infoln(err)
+ statelogger.Infoln(err)
}
}
@@ -172,10 +174,10 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
if err != nil {
if len(receipts) == len(block.Receipts()) {
for i, receipt := range block.Receipts() {
- ethutil.Config.Log.Debugf("diff (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", receipt.CumulativeGasUsed, receipt.PostState[0:4], receipts[i].CumulativeGasUsed, receipts[i].PostState[0:4], receipt.Tx.Hash())
+ statelogger.Debugf("diff (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", receipt.CumulativeGasUsed, receipt.PostState[0:4], receipts[i].CumulativeGasUsed, receipts[i].PostState[0:4], receipt.Tx.Hash())
}
} else {
- ethutil.Config.Log.Debugln("Unable to print receipt diff. Length didn't match", len(receipts), "for", len(block.Receipts()))
+ statelogger.Warnln("Unable to print receipt diff. Length didn't match", len(receipts), "for", len(block.Receipts()))
}
}
}()
@@ -186,19 +188,19 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
// Block validation
if err = sm.ValidateBlock(block); err != nil {
- fmt.Println("[SM] Error validating block:", err)
+ statelogger.Errorln("Error validating block:", err)
return err
}
// I'm not sure, but I don't know if there should be thrown
// any errors at this time.
if err = sm.AccumelateRewards(state, block); err != nil {
- fmt.Println("[SM] Error accumulating reward", err)
+ statelogger.Errorln("Error accumulating reward", err)
return err
}
if !block.State().Cmp(state) {
- err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().trie.Root, state.trie.Root)
+ statelogger.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().trie.Root, state.trie.Root)
return
}
@@ -211,7 +213,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
sm.bc.Add(block)
sm.notifyChanges(state)
- ethutil.Config.Log.Infof("[STATE] Added block #%d (%x)\n", block.Number, block.Hash())
+ statelogger.Infof("Added block #%d (%x)\n", block.Number, block.Hash())
if dontReact == false {
sm.Ethereum.Reactor().Post("newBlock", block)
@@ -222,7 +224,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
sm.Ethereum.TxPool().RemoveInvalid(state)
} else {
- fmt.Println("total diff failed")
+ statelogger.Errorln("total diff failed")
}
return nil