diff --git a/modules/transactionpool/accept.go b/modules/transactionpool/accept.go index 3393d49b4e..760037e6fe 100644 --- a/modules/transactionpool/accept.go +++ b/modules/transactionpool/accept.go @@ -331,32 +331,33 @@ func (tp *TransactionPool) AcceptTransactionSet(ts []types.Transaction) error { return errors.New("consensus set does not support LockedTryTransactionSet method") } - return cs.LockedTryTransactionSet(func(txnFn func(txns []types.Transaction) (modules.ConsensusChange, error)) error { + err := cs.LockedTryTransactionSet(func(txnFn func(txns []types.Transaction) (modules.ConsensusChange, error)) error { tp.mu.Lock() defer tp.mu.Unlock() err := tp.acceptTransactionSet(ts, txnFn) - // In case of certain errors we still want to broadcast the set - broadcast := err == nil || err == modules.ErrDuplicateTransactionSet - if broadcast { - // This set was broadcasted before if err != nil. We need to update - // it's seen txn height when we rebroadcast it. If we don't do - // that, the transaction will be pruned from the tpool and they - // might no longer show up in the wallet while still beingt - // tracked. - if err != nil { - for _, txn := range ts { - tp.transactionHeights[txn.ID()] = tp.blockHeight - } - } - go tp.gateway.Broadcast("RelayTransactionSet", ts, tp.gateway.Peers()) - } if err != nil { - return err + // Notify subscribers of an accepted transaction set + tp.updateSubscribersTransactions() } - // Notify subscribers of an accepted transaction set - tp.updateSubscribersTransactions() - return nil + return err }) + // In case of certain errors we still want to broadcast the set + if err == nil || err == modules.ErrDuplicateTransactionSet || err == errLowMinerFees { + // This set was broadcasted before if err != nil. We need to update + // it's seen txn height when we rebroadcast it. If we don't do + // that, the transaction will be pruned from the tpool and they + // might no longer show up in the wallet while still beingt + // tracked. + if err != nil { + tp.mu.Lock() + for _, txn := range ts { + tp.transactionHeights[txn.ID()] = tp.blockHeight + } + tp.mu.Unlock() + } + go tp.gateway.Broadcast("RelayTransactionSet", ts, tp.gateway.Peers()) + } + return err } // relayTransactionSet is an RPC that accepts a transaction set from a peer. If