|
|
|
@ -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, state *State, toContract bool) (err error) { |
|
|
|
|
func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract bool) (err error) { |
|
|
|
|
defer func() { |
|
|
|
|
if r := recover(); r != nil { |
|
|
|
|
log.Println(r) |
|
|
|
@ -98,7 +98,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, state *State, toContract |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
// Get the sender
|
|
|
|
|
sender := state.GetAccount(tx.Sender()) |
|
|
|
|
sender := block.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.
|
|
|
|
@ -112,7 +112,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, state *State, toContract |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get the receiver
|
|
|
|
|
receiver := state.GetAccount(tx.Recipient) |
|
|
|
|
receiver := block.state.GetAccount(tx.Recipient) |
|
|
|
|
sender.Nonce += 1 |
|
|
|
|
|
|
|
|
|
// Send Tx to self
|
|
|
|
@ -128,10 +128,10 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, state *State, toContract |
|
|
|
|
// Add the amount to receivers account which should conclude this transaction
|
|
|
|
|
receiver.Amount.Add(receiver.Amount, tx.Value) |
|
|
|
|
|
|
|
|
|
state.UpdateAccount(tx.Recipient, receiver) |
|
|
|
|
block.state.UpdateAccount(tx.Recipient, receiver) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
state.UpdateAccount(tx.Sender(), sender) |
|
|
|
|
block.state.UpdateAccount(tx.Sender(), sender) |
|
|
|
|
|
|
|
|
|
log.Printf("[TXPL] Processed Tx %x\n", tx.Hash()) |
|
|
|
|
|
|
|
|
|