forked from cerc-io/plugeth
Return proper error
This commit is contained in:
parent
a0266489b4
commit
03403399fc
@ -449,6 +449,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
self.setTransState(state.New(block.Root(), self.stateDb))
|
self.setTransState(state.New(block.Root(), self.stateDb))
|
||||||
|
self.setTxState(state.New(block.Root(), self.stateDb))
|
||||||
|
|
||||||
queue[i] = ChainEvent{block}
|
queue[i] = ChainEvent{block}
|
||||||
queueEvent.canonicalCount++
|
queueEvent.canonicalCount++
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,7 +78,7 @@ func (err *NonceErr) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NonceError(is, exp uint64) *NonceErr {
|
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 {
|
func IsNonceErr(err error) bool {
|
||||||
|
@ -148,6 +148,9 @@ func (self *StateTransition) preCheck() (err error) {
|
|||||||
|
|
||||||
// Pre-pay gas / Buy gas of the coinbase account
|
// Pre-pay gas / Buy gas of the coinbase account
|
||||||
if err = self.BuyGas(); err != nil {
|
if err = self.BuyGas(); err != nil {
|
||||||
|
if state.IsGasLimitErr(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return InvalidTxError(err)
|
return InvalidTxError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +212,7 @@ gasLimit:
|
|||||||
fallthrough
|
fallthrough
|
||||||
case core.IsInvalidTxErr(err):
|
case core.IsInvalidTxErr(err):
|
||||||
// Remove invalid transactions
|
// Remove invalid transactions
|
||||||
|
self.chain.TxState().RemoveNonce(tx.From(), tx.Nonce())
|
||||||
remove = append(remove, tx)
|
remove = append(remove, tx)
|
||||||
case state.IsGasLimitErr(err):
|
case state.IsGasLimitErr(err):
|
||||||
// Break on gas limit
|
// Break on gas limit
|
||||||
|
Loading…
Reference in New Issue
Block a user