From c3293641e7b49c7e2d85d2bd69b37bc74cb5b00d Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 30 Apr 2014 17:13:32 +0200 Subject: [PATCH] Removed debug logging --- ethchain/error.go | 23 ++++++++++++++++++++++- ethchain/state_manager.go | 2 +- ethchain/transaction_pool.go | 10 +++------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ethchain/error.go b/ethchain/error.go index 0f1d061c0d..8d37b0208a 100644 --- a/ethchain/error.go +++ b/ethchain/error.go @@ -1,6 +1,8 @@ package ethchain -import "fmt" +import ( + "fmt" +) // Parent error. In case a parent is unknown this error will be thrown // by the block manager @@ -40,3 +42,22 @@ func IsValidationErr(err error) bool { 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 +} diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 072fabc0e1..02d0345d75 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -157,7 +157,7 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error { hash := block.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 } diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go index 91fad2635b..fc807c580f 100644 --- a/ethchain/transaction_pool.go +++ b/ethchain/transaction_pool.go @@ -98,7 +98,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract } }() // Get the sender - sender := block.state.GetAccount(tx.Sender()) + sender := block.state.GetStateObject(tx.Sender()) 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) @@ -112,7 +112,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract } // Get the receiver - receiver := block.state.GetAccount(tx.Recipient) + receiver := block.state.GetStateObject(tx.Recipient) sender.Nonce += 1 // Send Tx to self @@ -169,7 +169,6 @@ out: for { select { case tx := <-pool.queueChan: - log.Println("Received new Tx to queue") hash := tx.Hash() foundTx := FindTx(pool.pool, func(tx *Transaction, e *list.Element) bool { return bytes.Compare(tx.Hash(), hash) == 0 @@ -186,11 +185,8 @@ out: log.Println("Validating Tx failed", err) } } else { - log.Println("Transaction ok, adding") - // Call blocking version. At this point it - // doesn't matter since this is a goroutine + // Call blocking version. pool.addTransaction(tx) - log.Println("Added") // Notify the subscribers pool.Ethereum.Reactor().Post("newTx", tx)