Removed debug logging

This commit is contained in:
obscuren 2014-04-30 17:13:32 +02:00
parent 21724f7ef9
commit c3293641e7
3 changed files with 26 additions and 9 deletions

@ -1,6 +1,8 @@
package ethchain package ethchain
import "fmt" import (
"fmt"
)
// Parent error. In case a parent is unknown this error will be thrown // Parent error. In case a parent is unknown this error will be thrown
// by the block manager // by the block manager
@ -40,3 +42,22 @@ func IsValidationErr(err error) bool {
return ok return ok
} }
type NonceErr struct {
Message string
Is, Exp uint64
}
func (err *NonceErr) Error() string {
return err.Message
}
func NonceError(is, exp uint64) *NonceErr {
return &NonceErr{Message: fmt.Sprintf("Nonce err. Is %d, expected %d", is, exp), Is: is, Exp: exp}
}
func IsNonceErr(err error) bool {
_, ok := err.(*NonceErr)
return ok
}

@ -157,7 +157,7 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
hash := block.Hash() hash := block.Hash()
if sm.bc.HasBlock(hash) { if sm.bc.HasBlock(hash) {
fmt.Println("[STATE] We already have this block, ignoring") //fmt.Println("[STATE] We already have this block, ignoring")
return nil return nil
} }

@ -98,7 +98,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
} }
}() }()
// Get the sender // Get the sender
sender := block.state.GetAccount(tx.Sender()) sender := block.state.GetStateObject(tx.Sender())
if sender.Nonce != tx.Nonce { if sender.Nonce != tx.Nonce {
return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead", sender.Nonce, tx.Nonce) return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead", sender.Nonce, tx.Nonce)
@ -112,7 +112,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
} }
// Get the receiver // Get the receiver
receiver := block.state.GetAccount(tx.Recipient) receiver := block.state.GetStateObject(tx.Recipient)
sender.Nonce += 1 sender.Nonce += 1
// Send Tx to self // Send Tx to self
@ -169,7 +169,6 @@ out:
for { for {
select { select {
case tx := <-pool.queueChan: case tx := <-pool.queueChan:
log.Println("Received new Tx to queue")
hash := tx.Hash() hash := tx.Hash()
foundTx := FindTx(pool.pool, func(tx *Transaction, e *list.Element) bool { foundTx := FindTx(pool.pool, func(tx *Transaction, e *list.Element) bool {
return bytes.Compare(tx.Hash(), hash) == 0 return bytes.Compare(tx.Hash(), hash) == 0
@ -186,11 +185,8 @@ out:
log.Println("Validating Tx failed", err) log.Println("Validating Tx failed", err)
} }
} else { } else {
log.Println("Transaction ok, adding") // Call blocking version.
// Call blocking version. At this point it
// doesn't matter since this is a goroutine
pool.addTransaction(tx) pool.addTransaction(tx)
log.Println("Added")
// Notify the subscribers // Notify the subscribers
pool.Ethereum.Reactor().Post("newTx", tx) pool.Ethereum.Reactor().Post("newTx", tx)