aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-01 16:41:30 +0800
committerobscuren <geffobscura@gmail.com>2014-04-01 16:41:30 +0800
commit7d0348e4baf45197ca506070e06e756a4ba6ccf6 (patch)
tree2f05e663ba1e3d7f8766f11c0b3fb1024fd3bed1 /ethchain/transaction_pool.go
parent7277c420479239fbea78417e42c43ee0162c2728 (diff)
downloadgo-tangerine-7d0348e4baf45197ca506070e06e756a4ba6ccf6.tar.gz
go-tangerine-7d0348e4baf45197ca506070e06e756a4ba6ccf6.tar.zst
go-tangerine-7d0348e4baf45197ca506070e06e756a4ba6ccf6.zip
Handle contract messages
Diffstat (limited to 'ethchain/transaction_pool.go')
-rw-r--r--ethchain/transaction_pool.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go
index 4a4f2e809..66828adfb 100644
--- a/ethchain/transaction_pool.go
+++ b/ethchain/transaction_pool.go
@@ -90,7 +90,7 @@ func (pool *TxPool) addTransaction(tx *Transaction) {
// Process transaction validates the Tx and processes funds from the
// sender to the recipient.
-func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error) {
+func (pool *TxPool) ProcessTransaction(tx *Transaction, state *State, toContract bool) (err error) {
defer func() {
if r := recover(); r != nil {
log.Println(r)
@@ -98,7 +98,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
}()
// Get the sender
- sender := block.state.GetAccount(tx.Sender())
+ sender := state.GetAccount(tx.Sender())
// Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it.
@@ -116,13 +116,15 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
// Get the receiver
- receiver := block.state.GetAccount(tx.Recipient)
+ receiver := state.GetAccount(tx.Recipient)
sender.Nonce += 1
// Send Tx to self
if bytes.Compare(tx.Recipient, tx.Sender()) == 0 {
// Subtract the fee
sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
+ } else if toContract {
+ sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
} else {
// Subtract the amount from the senders account
sender.Amount.Sub(sender.Amount, totAmount)
@@ -130,10 +132,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
// Add the amount to receivers account which should conclude this transaction
receiver.Amount.Add(receiver.Amount, tx.Value)
- block.state.UpdateAccount(tx.Recipient, receiver)
+ state.UpdateAccount(tx.Recipient, receiver)
}
- block.state.UpdateAccount(tx.Sender(), sender)
+ state.UpdateAccount(tx.Sender(), sender)
log.Printf("[TXPL] Processed Tx %x\n", tx.Hash())