Skip to content

Commit

Permalink
Return proper error
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Mar 13, 2015
1 parent a026648 commit 0340339
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/chain_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
*/

self.setTransState(state.New(block.Root(), self.stateDb))
self.setTxState(state.New(block.Root(), self.stateDb))

queue[i] = ChainEvent{block}
queueEvent.canonicalCount++
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (err *NonceErr) Error() string {
}

func NonceError(is, exp uint64) *NonceErr {
return &NonceErr{Message: fmt.Sprintf("Nonce err. Is %d, expected %d", is, exp), Is: is, Exp: exp}
return &NonceErr{Message: fmt.Sprintf("Transaction w/ invalid nonce (%d / %d)", is, exp), Is: is, Exp: exp}
}

func IsNonceErr(err error) bool {
Expand Down
3 changes: 3 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func (self *StateTransition) preCheck() (err error) {

// Pre-pay gas / Buy gas of the coinbase account
if err = self.BuyGas(); err != nil {
if state.IsGasLimitErr(err) {
return err
}
return InvalidTxError(err)
}

Expand Down
1 change: 1 addition & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ gasLimit:
fallthrough
case core.IsInvalidTxErr(err):
// Remove invalid transactions
self.chain.TxState().RemoveNonce(tx.From(), tx.Nonce())
remove = append(remove, tx)
case state.IsGasLimitErr(err):
// Break on gas limit
Expand Down

0 comments on commit 0340339

Please sign in to comment.