aboutsummaryrefslogtreecommitdiffstats
path: root/chain/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-02 03:18:09 +0800
committerobscuren <geffobscura@gmail.com>2014-12-02 03:18:09 +0800
commit6dc46d3341dc5fa25bd005f9606de258874139be (patch)
tree39b5d7dad5a943de4e187f99c93da5aa7fc9f2b8 /chain/transaction_pool.go
parenta3559c5e1b469890bb8d71e9992175febaae31c7 (diff)
downloaddexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar.gz
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar.bz2
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar.lz
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar.xz
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.tar.zst
dexon-6dc46d3341dc5fa25bd005f9606de258874139be.zip
Changed the way transactions are being added to the transaction pool
Diffstat (limited to 'chain/transaction_pool.go')
-rw-r--r--chain/transaction_pool.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/chain/transaction_pool.go b/chain/transaction_pool.go
index ff75089d6..fbf882163 100644
--- a/chain/transaction_pool.go
+++ b/chain/transaction_pool.go
@@ -114,7 +114,6 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
}
// Get the sender
- //sender := pool.Ethereum.BlockManager().procState.GetAccount(tx.Sender())
sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(tx.Sender())
totAmount := new(big.Int).Set(tx.Value)
@@ -136,6 +135,34 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
return nil
}
+func (self *TxPool) Add(tx *Transaction) error {
+ hash := tx.Hash()
+ foundTx := FindTx(self.pool, func(tx *Transaction, e *list.Element) bool {
+ return bytes.Compare(tx.Hash(), hash) == 0
+ })
+
+ if foundTx != nil {
+ return fmt.Errorf("Known transaction (%x)", hash[0:4])
+ }
+
+ err := self.ValidateTransaction(tx)
+ if err != nil {
+ return err
+ }
+
+ 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())
+
+ // Notify the subscribers
+ self.Ethereum.EventMux().Post(TxPreEvent{tx})
+
+ return nil
+}
+
func (pool *TxPool) queueHandler() {
out:
for {
@@ -172,9 +199,11 @@ out:
}
}
+/*
func (pool *TxPool) QueueTransaction(tx *Transaction) {
pool.queueChan <- tx
}
+*/
func (pool *TxPool) CurrentTransactions() []*Transaction {
pool.mutex.Lock()