Move erasure of non-active blocks to a separate loop in RewindBlockIndex
Move erasure of non-active blocks to a separate loop in RewindBlockIndex

This lets us simplify the iteration to just walking back in the chain,
rather than looping over all of mapBlockIndex.

Xekyo/bitcoin,fanquake/bitcoin,monacoinproject/monacoin,gjhiggins/vcoincore,rnicoll/bitcoin,MarcoFalke/bitcoin,alecalve/bitcoin,particl/particl-core,GroestlCoin/bitcoin,myriadcoin/myriadcoin,rnicoll/dogecoin,kallewoof/bitcoin,midnightmagic/bitcoin,domob1812/namecore,cdecker/bitcoin,pstratem/bitcoin,OmniLayer/omnicore,FeatherCoin/Feathercoin,tjps/bitcoin,bespike/litecoin,fujicoin/fujicoin,jonasschnelli/bitcoin,namecoin/namecore,yenliangl/bitcoin,tecnovert/particl-core,pataquets/namecoin-core,ajtowns/bitcoin,jtimon/bitcoin,domob1812/namecore,OmniLayer/omnicore,Xekyo/bitcoin,AkioNak/bitcoin,droark/bitcoin,jambolo/bitcoin,jlopp/statoshi,JeremyRubin/bitcoin,sstone/bitcoin,rnicoll/bitcoin,jnewbery/bitcoin,jtimon/bitcoin,mm-s/bitcoin,domob1812/bitcoin,kallewoof/bitcoin,pstratem/bitcoin,afk11/bitcoin,prusnak/bitcoin,MarcoFalke/bitcoin,fanquake/bitcoin,AkioNak/bitcoin,instagibbs/bitcoin,n1bor/bitcoin,OmniLayer/omnicore,OmniLayer/omnicore,DigitalPandacoin/pandacoin,lateminer/bitcoin,sstone/bitcoin,instagibbs/bitcoin,bitcoinknots/bitcoin,particl/particl-core,sstone/bitcoin,rnicoll/dogecoin,domob1812/namecore,andreaskern/bitcoin,ElementsProject/elements,mitchellcash/bitcoin,apoelstra/bitcoin,cdecker/bitcoin,nikkitan/bitcoin,peercoin/peercoin,namecoin/namecore,monacoinproject/monacoin,sipsorcery/bitcoin,qtumproject/qtum,namecoin/namecoin-core,bitcoin/bitcoin,achow101/bitcoin,yenliangl/bitcoin,FeatherCoin/Feathercoin,untrustbank/litecoin,namecoin/namecoin-core,jonasschnelli/bitcoin,ahmedbodi/vertcoin,JeremyRubin/bitcoin,MeshCollider/bitcoin,jambolo/bitcoin,vertcoin/vertcoin,peercoin/peercoin,qtumproject/qtum,fanquake/bitcoin,lateminer/bitcoin,vertcoin/vertcoin,n1bor/bitcoin,qtumproject/qtum,domob1812/namecore,GroestlCoin/GroestlCoin,prusnak/bitcoin,midnightmagic/bitcoin,bitcoinsSG/bitcoin,monacoinproject/monacoin,droark/bitcoin,tjps/bitcoin,namecoin/namecoin-core,Sjors/bitcoin,mruddy/bitcoin,gjhiggins/vcoincore,namecoin/namecoin-core,jambolo/bitcoin,mm-s/bitcoin,jnewbery/bitcoin,yenliangl/bitcoin,DigitalPandacoin/pandacoin,namecoin/namecoin-core,rnicoll/dogecoin,midnightmagic/bitcoin,bitcoinknots/bitcoin,andreaskern/bitcoin,bitcoin/bitcoin,dscotese/bitcoin,jnewbery/bitcoin,particl/particl-core,droark/bitcoin,bespike/litecoin,cdecker/bitcoin,pstratem/bitcoin,bitcoin/bitcoin,domob1812/bitcoin,mm-s/bitcoin,fanquake/bitcoin,vertcoin/vertcoin,MarcoFalke/bitcoin,litecoin-project/litecoin,jtimon/bitcoin,anditto/bitcoin,jamesob/bitcoin,bitcoinsSG/bitcoin,afk11/bitcoin,sstone/bitcoin,tecnovert/particl-core,MarcoFalke/bitcoin,afk11/bitcoin,litecoin-project/litecoin,ahmedbodi/vertcoin,DigitalPandacoin/pandacoin,practicalswift/bitcoin,mitchellcash/bitcoin,litecoin-project/litecoin,EthanHeilman/bitcoin,n1bor/bitcoin,kallewoof/bitcoin,pstratem/bitcoin,apoelstra/bitcoin,cdecker/bitcoin,jnewbery/bitcoin,andreaskern/bitcoin,MeshCollider/bitcoin,tjps/bitcoin,qtumproject/qtum,r8921039/bitcoin,fujicoin/fujicoin,alecalve/bitcoin,litecoin-project/litecoin,achow101/bitcoin,apoelstra/bitcoin,Xekyo/bitcoin,lateminer/bitcoin,qtumproject/qtum,pataquets/namecoin-core,Sjors/bitcoin,fujicoin/fujicoin,GroestlCoin/GroestlCoin,ElementsProject/elements,vertcoin/vertcoin,Sjors/bitcoin,namecoin/namecore,achow101/bitcoin,vertcoin/vertcoin,qtumproject/qtum,bitcoinsSG/bitcoin,andreaskern/bitcoin,fanquake/bitcoin,nikkitan/bitcoin,kallewoof/bitcoin,yenliangl/bitcoin,lateminer/bitcoin,achow101/bitcoin,gjhiggins/vcoincore,bespike/litecoin,prusnak/bitcoin,untrustbank/litecoin,practicalswift/bitcoin,GroestlCoin/bitcoin,bitcoin/bitcoin,midnightmagic/bitcoin,DigitalPandacoin/pandacoin,ajtowns/bitcoin,ElementsProject/elements,EthanHeilman/bitcoin,jamesob/bitcoin,JeremyRubin/bitcoin,r8921039/bitcoin,droark/bitcoin,sipsorcery/bitcoin,DigitalPandacoin/pandacoin,EthanHeilman/bitcoin,pstratem/bitcoin,dscotese/bitcoin,instagibbs/bitcoin,monacoinproject/monacoin,particl/particl-core,instagibbs/bitcoin,wellenreiter01/Feathercoin,pataquets/namecoin-core,wellenreiter01/Feathercoin,jonasschnelli/bitcoin,jamesob/bitcoin,dscotese/bitcoin,rnicoll/dogecoin,JeremyRubin/bitcoin,domob1812/bitcoin,jambolo/bitcoin,ajtowns/bitcoin,wellenreiter01/Feathercoin,mruddy/bitcoin,yenliangl/bitcoin,lateminer/bitcoin,bitcoinknots/bitcoin,MeshCollider/bitcoin,GroestlCoin/GroestlCoin,jlopp/statoshi,rnicoll/bitcoin,ajtowns/bitcoin,domob1812/namecore,Sjors/bitcoin,anditto/bitcoin,CryptArc/bitcoin,r8921039/bitcoin,tecnovert/particl-core,bitcoin/bitcoin,r8921039/bitcoin,wellenreiter01/Feathercoin,r8921039/bitcoin,practicalswift/bitcoin,jnewbery/bitcoin,FeatherCoin/Feathercoin,sstone/bitcoin,peercoin/peercoin,bitcoinknots/bitcoin,achow101/bitcoin,afk11/bitcoin,ajtowns/bitcoin,mruddy/bitcoin,GroestlCoin/bitcoin,pataquets/namecoin-core,sipsorcery/bitcoin,apoelstra/bitcoin,mruddy/bitcoin,anditto/bitcoin,jamesob/bitcoin,anditto/bitcoin,mitchellcash/bitcoin,myriadteam/myriadcoin,Xekyo/bitcoin,mitchellcash/bitcoin,ahmedbodi/vertcoin,myriadcoin/myriadcoin,JeremyRubin/bitcoin,MarcoFalke/bitcoin,CryptArc/bitcoin,particl/particl-core,bitcoinknots/bitcoin,untrustbank/litecoin,myriadteam/myriadcoin,mm-s/bitcoin,untrustbank/litecoin,jlopp/statoshi,prusnak/bitcoin,FeatherCoin/Feathercoin,wellenreiter01/Feathercoin,sstone/bitcoin,peercoin/peercoin,jonasschnelli/bitcoin,alecalve/bitcoin,gjhiggins/vcoincore,Sjors/bitcoin,jonasschnelli/bitcoin,nikkitan/bitcoin,fujicoin/fujicoin,ahmedbodi/vertcoin,r8921039/bitcoin,domob1812/bitcoin,dscotese/bitcoin,jtimon/bitcoin,monacoinproject/monacoin,instagibbs/bitcoin,achow101/bitcoin,myriadcoin/myriadcoin,gjhiggins/vcoincore,JeremyRubin/bitcoin,bitcoin/bitcoin,untrustbank/litecoin,sipsorcery/bitcoin,mitchellcash/bitcoin,tecnovert/particl-core,pstratem/bitcoin,tjps/bitcoin,wellenreiter01/Feathercoin,domob1812/namecore,pataquets/namecoin-core,afk11/bitcoin,OmniLayer/omnicore,fanquake/bitcoin,practicalswift/bitcoin,midnightmagic/bitcoin,alecalve/bitcoin,fujicoin/fujicoin,untrustbank/litecoin,tecnovert/particl-core,GroestlCoin/bitcoin,sipsorcery/bitcoin,myriadcoin/myriadcoin,droark/bitcoin,bespike/litecoin,fujicoin/fujicoin,jambolo/bitcoin,MarcoFalke/bitcoin,mruddy/bitcoin,peercoin/peercoin,domob1812/bitcoin,tjps/bitcoin,mm-s/bitcoin,afk11/bitcoin,ajtowns/bitcoin,nikkitan/bitcoin,practicalswift/bitcoin,FeatherCoin/Feathercoin,peercoin/peercoin,MeshCollider/bitcoin,rnicoll/bitcoin,litecoin-project/litecoin,qtumproject/qtum,EthanHeilman/bitcoin,jlopp/statoshi,monacoinproject/monacoin,jtimon/bitcoin,bitcoinsSG/bitcoin,ahmedbodi/vertcoin,CryptArc/bitcoin,FeatherCoin/Feathercoin,MeshCollider/bitcoin,tjps/bitcoin,GroestlCoin/bitcoin,GroestlCoin/GroestlCoin,dscotese/bitcoin,nikkitan/bitcoin,namecoin/namecoin-core,tecnovert/particl-core,AkioNak/bitcoin,prusnak/bitcoin,prusnak/bitcoin,myriadteam/myriadcoin,droark/bitcoin,ElementsProject/elements,rnicoll/bitcoin,gjhiggins/vcoincore,DigitalPandacoin/pandacoin,anditto/bitcoin,GroestlCoin/GroestlCoin,apoelstra/bitcoin,myriadcoin/myriadcoin,bespike/litecoin,midnightmagic/bitcoin,particl/particl-core,GroestlCoin/bitcoin,alecalve/bitcoin,cdecker/bitcoin,myriadteam/myriadcoin,jamesob/bitcoin,mruddy/bitcoin,n1bor/bitcoin,anditto/bitcoin,myriadteam/myriadcoin,AkioNak/bitcoin,CryptArc/bitcoin,ElementsProject/elements,Xekyo/bitcoin,EthanHeilman/bitcoin,bitcoinsSG/bitcoin,cdecker/bitcoin,sipsorcery/bitcoin,nikkitan/bitcoin,andreaskern/bitcoin,n1bor/bitcoin,jlopp/statoshi,kallewoof/bitcoin,mm-s/bitcoin,litecoin-project/litecoin,Xekyo/bitcoin,jamesob/bitcoin,namecoin/namecore,jambolo/bitcoin,yenliangl/bitcoin,jlopp/statoshi,lateminer/bitcoin,n1bor/bitcoin,namecoin/namecore,ahmedbodi/vertcoin,bespike/litecoin,CryptArc/bitcoin,AkioNak/bitcoin,MeshCollider/bitcoin,OmniLayer/omnicore,instagibbs/bitcoin,rnicoll/bitcoin,andreaskern/bitcoin,apoelstra/bitcoin,vertcoin/vertcoin,myriadteam/myriadcoin,ElementsProject/elements,practicalswift/bitcoin,namecoin/namecore,CryptArc/bitcoin,pataquets/namecoin-core,AkioNak/bitcoin,bitcoinsSG/bitcoin,domob1812/bitcoin,rnicoll/dogecoin,kallewoof/bitcoin,myriadcoin/myriadcoin,GroestlCoin/GroestlCoin,EthanHeilman/bitcoin,mitchellcash/bitcoin,jtimon/bitcoin,dscotese/bitcoin,alecalve/bitcoin