aboutsummaryrefslogtreecommitdiffstats
path: root/core/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-18 22:18:13 +0800
committerobscuren <geffobscura@gmail.com>2014-12-18 22:18:13 +0800
commitdb494170dc819b1eb0d267b6e1ab36c6cfb63569 (patch)
tree8e2b374519a0ae5e20a9db0c2a4a86bf3375329e /core/transaction_pool.go
parent9e286e1c337319f47b2b04e9e1022ac05470a296 (diff)
downloadgo-tangerine-db494170dc819b1eb0d267b6e1ab36c6cfb63569.tar.gz
go-tangerine-db494170dc819b1eb0d267b6e1ab36c6cfb63569.tar.zst
go-tangerine-db494170dc819b1eb0d267b6e1ab36c6cfb63569.zip
Created generic message (easy for testing)
Diffstat (limited to 'core/transaction_pool.go')
-rw-r--r--core/transaction_pool.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index 36b0beb28..da91ec568 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -112,8 +112,8 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return fmt.Errorf("No last block on the block chain")
}
- if len(tx.Recipient) != 0 && len(tx.Recipient) != 20 {
- return fmt.Errorf("Invalid recipient. len = %d", len(tx.Recipient))
+ if len(tx.To()) != 0 && len(tx.To()) != 20 {
+ return fmt.Errorf("Invalid recipient. len = %d", len(tx.To()))
}
v, _, _ := tx.Curve()
@@ -124,15 +124,15 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
// Get the sender
sender := pool.chainManager.State().GetAccount(tx.Sender())
- totAmount := new(big.Int).Set(tx.Value)
+ totAmount := new(big.Int).Set(tx.Value())
// Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it.
if sender.Balance().Cmp(totAmount) < 0 {
- return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.Sender())
+ return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From())
}
if tx.IsContract() {
- if tx.GasPrice.Cmp(big.NewInt(minGasPrice)) < 0 {
+ if tx.GasPrice().Cmp(big.NewInt(minGasPrice)) < 0 {
return fmt.Errorf("Gasprice too low, %s given should be at least %d.", tx.GasPrice, minGasPrice)
}
}
@@ -160,10 +160,7 @@ func (self *TxPool) Add(tx *types.Transaction) error {
self.addTransaction(tx)
- tmp := make([]byte, 4)
- copy(tmp, tx.Recipient)
-
- txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.Sender()[:4], tmp, tx.Value, tx.Hash())
+ txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.From()[:4], tx.To()[:4], tx.Value, tx.Hash())
// Notify the subscribers
go self.eventMux.Post(TxPreEvent{tx})
@@ -200,7 +197,7 @@ func (pool *TxPool) RemoveInvalid(state *state.StateDB) {
tx := e.Value.(*types.Transaction)
sender := state.GetAccount(tx.Sender())
err := pool.ValidateTransaction(tx)
- if err != nil || sender.Nonce >= tx.Nonce {
+ if err != nil || sender.Nonce >= tx.Nonce() {
pool.pool.Remove(e)
}
}