Fixed minor issue with gas and added state object init

This commit is contained in:
obscuren
2014-04-23 11:51:04 +02:00
parent 61cd1594b5
commit 3a9a252f6e
7 changed files with 135 additions and 56 deletions

View File

@@ -104,7 +104,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
// funds won't invalidate this transaction but simple ignores it.
totAmount := new(big.Int).Add(tx.Value, new(big.Int).Mul(TxFee, TxFeeRat))
if sender.Amount.Cmp(totAmount) < 0 {
return errors.New("[TXPL] Insufficient amount in sender's account")
return fmt.Errorf("[TXPL] Insufficient amount in sender's (%x) account", tx.Sender())
}
if sender.Nonce != tx.Nonce {
@@ -119,8 +119,6 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
if bytes.Compare(tx.Recipient, tx.Sender()) == 0 {
// Subtract the fee
sender.SubAmount(new(big.Int).Mul(TxFee, TxFeeRat))
} else if toContract {
sender.SubAmount(new(big.Int).Mul(TxFee, TxFeeRat))
} else {
// Subtract the amount from the senders account
sender.SubAmount(totAmount)