@@ -91,8 +91,9 @@ func (self *TxPool) addTx(tx *types.Transaction) {
9191}
9292
9393func (self * TxPool ) add (tx * types.Transaction ) error {
94- if self .txs [tx .Hash ()] != nil {
95- return fmt .Errorf ("Known transaction (%x)" , tx .Hash ()[0 :4 ])
94+ hash := tx .Hash ()
95+ if self .txs [hash ] != nil {
96+ return fmt .Errorf ("Known transaction (%x)" , hash [0 :4 ])
9697 }
9798 err := self .ValidateTransaction (tx )
9899 if err != nil {
@@ -102,7 +103,7 @@ func (self *TxPool) add(tx *types.Transaction) error {
102103 self .addTx (tx )
103104
104105 var toname string
105- if to , valid := tx .To (); valid {
106+ if to := tx .To (); to != nil {
106107 toname = common .Bytes2Hex (to [:4 ])
107108 } else {
108109 toname = "[NEW_CONTRACT]"
@@ -111,7 +112,7 @@ func (self *TxPool) add(tx *types.Transaction) error {
111112 // verified in ValidateTransaction.
112113 f , _ := tx .From ()
113114 from := common .Bytes2Hex (f [:4 ])
114- txplogger .Debugf ("(t) %x => %s (%v) %x\n " , from , to , tx .Value , tx .Hash ())
115+ txplogger .Debugf ("(t) %x => %s (%v) %x\n " , from , toname , tx .Value , tx .Hash ())
115116
116117 // Notify the subscribers
117118 go self .eventMux .Post (TxPreEvent {tx })
@@ -137,7 +138,8 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
137138 if err := self .add (tx ); err != nil {
138139 txplogger .Debugln (err )
139140 } else {
140- txplogger .Debugf ("tx %x\n " , tx .Hash ()[0 :4 ])
141+ h := tx .Hash ()
142+ txplogger .Debugf ("tx %x\n " , h [:4 ])
141143 }
142144 }
143145}
@@ -161,7 +163,8 @@ func (pool *TxPool) RemoveInvalid(query StateQuery) {
161163
162164 var removedTxs types.Transactions
163165 for _ , tx := range pool .txs {
164- sender := query .GetAccount (tx .From ())
166+ from , _ := tx .From ()
167+ sender := query .GetAccount (from [:])
165168 err := pool .ValidateTransaction (tx )
166169 if err != nil || sender .Nonce () >= tx .Nonce () {
167170 removedTxs = append (removedTxs , tx )
0 commit comments