Handle another removal case missed in prev commit.

Also, the loops which only remove a single element and break or return
don't need the extra logic for iteration since they don't continue
iteration after removal.
This commit is contained in:
Dave Collins 2013-10-07 10:10:10 -05:00
parent 219a6131f4
commit 995d8da491
3 changed files with 6 additions and 10 deletions

View file

@ -189,9 +189,7 @@ func (b *blockManager) handleNewPeerMsg(peers *list.List, p *peer) {
// is invoked from the syncHandler goroutine.
func (b *blockManager) handleDonePeerMsg(peers *list.List, p *peer) {
// Remove the peer from the list of candidate peers.
var enext *list.Element
for e := peers.Front(); e != nil; e = enext {
enext = e.Next()
for e := peers.Front(); e != nil; e = e.Next() {
if e.Value == p {
peers.Remove(e)
break

View file

@ -292,9 +292,7 @@ func (mp *txMemPool) removeOrphan(txHash *btcwire.ShaHash) {
for _, txIn := range tx.TxIn {
originTxHash := txIn.PreviousOutpoint.Hash
if orphans, exists := mp.orphansByPrev[originTxHash]; exists {
var enext *list.Element
for e := orphans.Front(); e != nil; e = enext {
enext = e.Next()
for e := orphans.Front(); e != nil; e = e.Next() {
if e.Value.(*btcwire.MsgTx) == tx {
orphans.Remove(e)
break
@ -701,7 +699,9 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
continue
}
for e := orphans.Front(); e != nil; e = e.Next() {
var enext *list.Element
for e := orphans.Front(); e != nil; e = enext {
enext = e.Next()
tx := e.Value.(*btcwire.MsgTx)
// Remove the orphan from the orphan pool.

View file

@ -116,9 +116,7 @@ func (s *server) handleAddPeerMsg(peers *list.List, banned map[string]time.Time,
// handleDonePeerMsg deals with peers that have signalled they are done. It is
// invoked from the peerHandler goroutine.
func (s *server) handleDonePeerMsg(peers *list.List, p *peer) bool {
var enext *list.Element
for e := peers.Front(); e != nil; e = enext {
enext = e.Next()
for e := peers.Front(); e != nil; e = e.Next() {
if e.Value == p {
// Issue an asynchronous reconnect if the peer was a
// persistent outbound connection.