Moved logging to logger.Core

pull/632/merge
obscuren 10 years ago
parent 218bfeb60e
commit 1889727144
  1. 4
      core/block_processor.go
  2. 8
      core/state/state_object.go
  3. 2
      core/state/statedb.go
  4. 7
      core/state_transition.go
  5. 1
      logger/verbosity.go
  6. 2
      whisper/whisper.go

@ -257,8 +257,8 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b)
} }
// Allow future blocks up to 4 seconds // Allow future blocks up to 10 seconds
if int64(block.Time)+4 > time.Now().Unix() { if int64(block.Time)+10 > time.Now().Unix() {
return BlockFutureErr return BlockFutureErr
} }

@ -124,7 +124,7 @@ func (self *StateObject) MarkForDeletion() {
self.remove = true self.remove = true
self.dirty = true self.dirty = true
if glog.V(logger.Debug) { if glog.V(logger.Core) {
glog.Infof("%x: #%d %v X\n", self.Address(), self.nonce, self.balance) glog.Infof("%x: #%d %v X\n", self.Address(), self.nonce, self.balance)
} }
} }
@ -190,7 +190,7 @@ func (c *StateObject) GetInstr(pc *big.Int) *common.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))
if glog.V(logger.Debug) { if glog.V(logger.Core) {
glog.Infof("%x: #%d %v (+ %v)\n", c.Address(), c.nonce, c.balance, amount) glog.Infof("%x: #%d %v (+ %v)\n", c.Address(), c.nonce, c.balance, amount)
} }
} }
@ -198,7 +198,7 @@ func (c *StateObject) AddBalance(amount *big.Int) {
func (c *StateObject) SubBalance(amount *big.Int) { func (c *StateObject) SubBalance(amount *big.Int) {
c.SetBalance(new(big.Int).Sub(c.balance, amount)) c.SetBalance(new(big.Int).Sub(c.balance, amount))
if glog.V(logger.Debug) { if glog.V(logger.Core) {
glog.Infof("%x: #%d %v (- %v)\n", c.Address(), c.nonce, c.balance, amount) glog.Infof("%x: #%d %v (- %v)\n", c.Address(), c.nonce, c.balance, amount)
} }
} }
@ -234,7 +234,7 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
func (self *StateObject) SetGasPool(gasLimit *big.Int) { func (self *StateObject) SetGasPool(gasLimit *big.Int) {
self.gasPool = new(big.Int).Set(gasLimit) self.gasPool = new(big.Int).Set(gasLimit)
if glog.V(logger.Debug) { if glog.V(logger.Core) {
glog.Infof("%x: gas (+ %v)", self.Address(), self.gasPool) glog.Infof("%x: gas (+ %v)", self.Address(), self.gasPool)
} }
} }

@ -209,7 +209,7 @@ func (self *StateDB) GetOrNewStateObject(addr common.Address) *StateObject {
// NewStateObject create a state object whether it exist in the trie or not // NewStateObject create a state object whether it exist in the trie or not
func (self *StateDB) newStateObject(addr common.Address) *StateObject { func (self *StateDB) newStateObject(addr common.Address) *StateObject {
if glog.V(logger.Debug) { if glog.V(logger.Core) {
glog.Infof("(+) %x\n", addr) glog.Infof("(+) %x\n", addr)
} }

@ -8,6 +8,8 @@ import (
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
) )
@ -166,9 +168,6 @@ func (self *StateTransition) preCheck() (err error) {
} }
func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, err error) { func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, err error) {
// statelogger.Debugf("(~) %x\n", self.msg.Hash())
// XXX Transactions after this point are considered valid.
if err = self.preCheck(); err != nil { if err = self.preCheck(); err != nil {
return return
} }
@ -207,7 +206,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
if err := self.UseGas(dataGas); err == nil { if err := self.UseGas(dataGas); err == nil {
ref.SetCode(ret) ref.SetCode(ret)
} else { } else {
statelogger.Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas) glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas)
} }
} }
} else { } else {

@ -3,6 +3,7 @@ package logger
const ( const (
Error = iota + 2 Error = iota + 2
Info Info
Core
Debug Debug
Detail Detail
) )

@ -168,7 +168,7 @@ func (self *Whisper) msgHandler(peer *p2p.Peer, ws p2p.MsgReadWriter) error {
for _, envelope := range envelopes { for _, envelope := range envelopes {
if err := self.add(envelope); err != nil { if err := self.add(envelope); err != nil {
// TODO Punish peer here. Invalid envelope. // TODO Punish peer here. Invalid envelope.
peer.Infoln(err) peer.Debugln(err)
} }
wpeer.addKnown(envelope) wpeer.addKnown(envelope)
} }

Loading…
Cancel
Save