@@ -125,11 +125,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
125125 return nil
126126}
127127
128- func (self * TxPool ) addTx (tx * types.Transaction ) {
129- from , _ := tx .From ()
130- self .queue [from ] = append (self .queue [from ], tx )
131- }
132-
133128func (self * TxPool ) add (tx * types.Transaction ) error {
134129 hash := tx .Hash ()
135130
@@ -147,7 +142,7 @@ func (self *TxPool) add(tx *types.Transaction) error {
147142 return err
148143 }
149144
150- self .addTx (tx )
145+ self .queueTx (tx )
151146
152147 var toname string
153148 if to := tx .To (); to != nil {
@@ -226,6 +221,19 @@ func (pool *TxPool) Stop() {
226221 glog .V (logger .Info ).Infoln ("TX Pool stopped" )
227222}
228223
224+ func (self * TxPool ) queueTx (tx * types.Transaction ) {
225+ from , _ := tx .From ()
226+ self .queue [from ] = append (self .queue [from ], tx )
227+ }
228+
229+ func (pool * TxPool ) addTx (tx * types.Transaction ) {
230+ if _ , ok := pool .txs [tx .Hash ()]; ! ok {
231+ pool .txs [tx .Hash ()] = tx
232+ // Notify the subscribers
233+ pool .eventMux .Post (TxPreEvent {tx })
234+ }
235+ }
236+
229237// check queue will attempt to insert
230238func (pool * TxPool ) checkQueue () {
231239 pool .mu .Lock ()
@@ -257,9 +265,7 @@ func (pool *TxPool) checkQueue() {
257265 }
258266 enonce ++
259267
260- pool .txs [tx .Hash ()] = tx
261- // Notify the subscribers
262- go pool .eventMux .Post (TxPreEvent {tx })
268+ pool .addTx (tx )
263269 }
264270 //pool.queue[address] = txs[i:]
265271 // delete the entire queue entry if it's empty. There's no need to keep it
0 commit comments