Skip to content
This repository was archived by the owner on Nov 2, 2018. It is now read-only.

Commit 0d3edb8

Browse files
move broadcast out of lockedTryTransactionSet
1 parent ad50676 commit 0d3edb8

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

modules/transactionpool/accept.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -331,35 +331,38 @@ func (tp *TransactionPool) AcceptTransactionSet(ts []types.Transaction) error {
331331
return errors.New("consensus set does not support LockedTryTransactionSet method")
332332
}
333333

334-
return cs.LockedTryTransactionSet(func(txnFn func(txns []types.Transaction) (modules.ConsensusChange, error)) error {
335-
tp.log.Println("Beginning broadcast of transaction set")
334+
tp.log.Println("Beginning broadcast of transaction set")
335+
err := cs.LockedTryTransactionSet(func(txnFn func(txns []types.Transaction) (modules.ConsensusChange, error)) error {
336336
tp.mu.Lock()
337337
defer tp.mu.Unlock()
338338
err := tp.acceptTransactionSet(ts, txnFn)
339-
// In case of certain errors we still want to broadcast the set
340-
broadcast := err == nil || err == modules.ErrDuplicateTransactionSet
341-
if broadcast {
342-
// This set was broadcasted before if err != nil. We need to update
343-
// it's seen txn height when we rebroadcast it. If we don't do
344-
// that, the transaction will be pruned from the tpool and they
345-
// might no longer show up in the wallet while still beingt
346-
// tracked.
347-
if err != nil {
348-
for _, txn := range ts {
349-
tp.transactionHeights[txn.ID()] = tp.blockHeight
350-
}
351-
}
352-
go tp.gateway.Broadcast("RelayTransactionSet", ts, tp.gateway.Peers())
353-
}
354339
if err != nil {
355-
tp.log.Println("Transaction set broadcast has failed")
356340
return err
357341
}
358342
// Notify subscribers of an accepted transaction set
359343
tp.updateSubscribersTransactions()
360-
tp.log.Println("Transaction set broadcast appears to have succeeded")
361344
return nil
362345
})
346+
// In case of certain errors we still want to broadcast the set
347+
if err == nil || err == modules.ErrDuplicateTransactionSet || err == errLowMinerFees {
348+
// This set was broadcasted before if err != nil. We need to update
349+
// it's seen txn height when we rebroadcast it. If we don't do
350+
// that, the transaction will be pruned from the tpool and they
351+
// might no longer show up in the wallet while still beingt
352+
// tracked.
353+
if err != nil {
354+
tp.mu.Lock()
355+
for _, txn := range ts {
356+
tp.transactionHeights[txn.ID()] = tp.blockHeight
357+
}
358+
tp.mu.Unlock()
359+
}
360+
go tp.gateway.Broadcast("RelayTransactionSet", ts, tp.gateway.Peers())
361+
tp.log.Println("Transaction set broadcast appears to have succeeded")
362+
} else {
363+
tp.log.Println("Transaction set broadcast has failed")
364+
}
365+
return err
363366
}
364367

365368
// relayTransactionSet is an RPC that accepts a transaction set from a peer. If

0 commit comments

Comments
 (0)