Only call NotifyBlockTip when the active chain changes
Only call NotifyBlockTip when the active chain changes

Previously, if `invalidateblock` was called on a block in a branch,
NotifyBlockTip would be called on that block's predecessor, creating an
incorrect `rpc/blockchain.cpp:latestblock` value.

Only call NotifyBlockTip if the chain being modified is activeChain.

rawodb/bitcoin,jonasschnelli/bitcoin,FeatherCoin/Feathercoin,CryptArc/bitcoin,fujicoin/fujicoin,mruddy/bitcoin,andreaskern/bitcoin,instagibbs/bitcoin,paveljanik/bitcoin,FeatherCoin/Feathercoin,Xekyo/bitcoin,wellenreiter01/Feathercoin,Xekyo/bitcoin,myriadcoin/myriadcoin,gjhiggins/vcoincore,ElementsProject/elements,jtimon/bitcoin,bitcoin/bitcoin,vmp32k/litecoin,Kogser/bitcoin,ajtowns/bitcoin,ajtowns/bitcoin,r8921039/bitcoin,qtumproject/qtum,fanquake/bitcoin,OmniLayer/omnicore,mruddy/bitcoin,myriadcoin/myriadcoin,mruddy/bitcoin,BTCGPU/BTCGPU,ajtowns/bitcoin,droark/bitcoin,jtimon/bitcoin,sipsorcery/bitcoin,h4x3rotab/BTCGPU,ajtowns/bitcoin,bespike/litecoin,instagibbs/bitcoin,GlobalBoost/GlobalBoost,vmp32k/litecoin,ahmedbodi/vertcoin,RHavar/bitcoin,jambolo/bitcoin,anditto/bitcoin,bitcoinknots/bitcoin,sebrandon1/bitcoin,MarcoFalke/bitcoin,Kogser/bitcoin,stamhe/bitcoin,Christewart/bitcoin,namecoin/namecoin-core,afk11/bitcoin,EthanHeilman/bitcoin,mm-s/bitcoin,tjps/bitcoin,alecalve/bitcoin,sebrandon1/bitcoin,bespike/litecoin,andreaskern/bitcoin,particl/particl-core,tecnovert/particl-core,sstone/bitcoin,tecnovert/particl-core,fujicoin/fujicoin,EthanHeilman/bitcoin,jamesob/bitcoin,anditto/bitcoin,lateminer/bitcoin,rnicoll/bitcoin,CryptArc/bitcoin,digibyte/digibyte,RHavar/bitcoin,GroestlCoin/bitcoin,bitcoin/bitcoin,Kogser/bitcoin,lateminer/bitcoin,Flowdalic/bitcoin,GlobalBoost/GlobalBoost,OmniLayer/omnicore,GroestlCoin/GroestlCoin,peercoin/peercoin,sipsorcery/bitcoin,tjps/bitcoin,JeremyRubin/bitcoin,jambolo/bitcoin,untrustbank/litecoin,AkioNak/bitcoin,vmp32k/litecoin,kallewoof/bitcoin,jamesob/bitcoin,jonasschnelli/bitcoin,alecalve/bitcoin,lateminer/bitcoin,Kogser/bitcoin,thrasher-/litecoin,bespike/litecoin,nikkitan/bitcoin,GlobalBoost/GlobalBoost,nikkitan/bitcoin,achow101/bitcoin,domob1812/huntercore,n1bor/bitcoin,sebrandon1/bitcoin,TheBlueMatt/bitcoin,digibyte/digibyte,thrasher-/litecoin,DigitalPandacoin/pandacoin,jlopp/statoshi,Kogser/bitcoin,peercoin/peercoin,ahmedbodi/vertcoin,midnightmagic/bitcoin,fujicoin/fujicoin,bitcoinknots/bitcoin,r8921039/bitcoin,untrustbank/litecoin,cdecker/bitcoin,BTCGPU/BTCGPU,ericshawlinux/bitcoin,jamesob/bitcoin,pstratem/bitcoin,apoelstra/bitcoin,lateminer/bitcoin,andreaskern/bitcoin,kallewoof/bitcoin,Sjors/bitcoin,bitcoin/bitcoin,paveljanik/bitcoin,practicalswift/bitcoin,paveljanik/bitcoin,vmp32k/litecoin,practicalswift/bitcoin,pataquets/namecoin-core,RHavar/bitcoin,prusnak/bitcoin,randy-waterhouse/bitcoin,particl/particl-core,prusnak/bitcoin,JeremyRubin/bitcoin,TheBlueMatt/bitcoin,pstratem/bitcoin,MarcoFalke/bitcoin,stamhe/bitcoin,gjhiggins/vcoincore,mm-s/bitcoin,prusnak/bitcoin,practicalswift/bitcoin,apoelstra/bitcoin,sipsorcery/bitcoin,Christewart/bitcoin,nikkitan/bitcoin,DigitalPandacoin/pandacoin,mitchellcash/bitcoin,n1bor/bitcoin,Christewart/bitcoin,tjps/bitcoin,monacoinproject/monacoin,DigitalPandacoin/pandacoin,EthanHeilman/bitcoin,jnewbery/bitcoin,h4x3rotab/BTCGPU,guncoin/guncoin,ericshawlinux/bitcoin,monacoinproject/monacoin,guncoin/guncoin,nikkitan/bitcoin,rnicoll/dogecoin,domob1812/namecore,wellenreiter01/Feathercoin,fujicoin/fujicoin,prusnak/bitcoin,Flowdalic/bitcoin,TheBlueMatt/bitcoin,FeatherCoin/Feathercoin,peercoin/peercoin,lbryio/lbrycrd,anditto/bitcoin,monacoinproject/monacoin,stamhe/bitcoin,monacoinproject/monacoin,myriadteam/myriadcoin,afk11/bitcoin,pataquets/namecoin-core,Bushstar/UFO-Project,Flowdalic/bitcoin,untrustbank/litecoin,OmniLayer/omnicore,litecoin-project/litecoin,rnicoll/bitcoin,particl/particl-core,Xekyo/bitcoin,joshrabinowitz/bitcoin,tecnovert/particl-core,jambolo/bitcoin,myriadcoin/myriadcoin,domob1812/bitcoin,rnicoll/dogecoin,vertcoin/vertcoin,MarcoFalke/bitcoin,randy-waterhouse/bitcoin,pstratem/bitcoin,JeremyRubin/bitcoin,achow101/bitcoin,instagibbs/bitcoin,DigitalPandacoin/pandacoin,digibyte/digibyte,lateminer/bitcoin,jlopp/statoshi,apoelstra/bitcoin,CryptArc/bitcoin,prusnak/bitcoin,n1bor/bitcoin,AkioNak/bitcoin,jonasschnelli/bitcoin,mm-s/bitcoin,ericshawlinux/bitcoin,kallewoof/bitcoin,untrustbank/litecoin,jnewbery/bitcoin,domob1812/bitcoin,jambolo/bitcoin,bitcoinsSG/bitcoin,Kogser/bitcoin,vertcoin/vertcoin,CryptArc/bitcoin,domob1812/huntercore,gjhiggins/vcoincore,qtumproject/qtum,digibyte/digibyte,rawodb/bitcoin,rnicoll/bitcoin,mruddy/bitcoin,donaloconnor/bitcoin,dscotese/bitcoin,EthanHeilman/bitcoin,droark/bitcoin,wellenreiter01/Feathercoin,MarcoFalke/bitcoin,lbryio/lbrycrd,anditto/bitcoin,jamesob/bitcoin,BTCGPU/BTCGPU,AkioNak/bitcoin,r8921039/bitcoin,bespike/litecoin,randy-waterhouse/bitcoin,AkioNak/bitcoin,midnightmagic/bitcoin,Sjors/bitcoin,MeshCollider/bitcoin,dscotese/bitcoin,myriadcoin/myriadcoin,ericshawlinux/bitcoin,bitcoinsSG/bitcoin,tecnovert/particl-core,cdecker/bitcoin,pstratem/bitcoin,h4x3rotab/BTCGPU,jamesob/bitcoin,donaloconnor/bitcoin,apoelstra/bitcoin,jlopp/statoshi,DigitalPandacoin/pandacoin,domob1812/bitcoin,particl/particl-core,Kogser/bitcoin,wellenreiter01/Feathercoin,joshrabinowitz/bitcoin,Bushstar/UFO-Project,tecnovert/particl-core,domob1812/bitcoin,jambolo/bitcoin,mitchellcash/bitcoin,jmcorgan/bitcoin,fanquake/bitcoin,anditto/bitcoin,yenliangl/bitcoin,Kogser/bitcoin,domob1812/huntercore,sipsorcery/bitcoin,tjps/bitcoin,sipsorcery/bitcoin,jamesob/bitcoin,anditto/bitcoin,droark/bitcoin,mm-s/bitcoin,vertcoin/vertcoin,tecnovert/particl-core,h4x3rotab/BTCGPU,untrustbank/litecoin,droark/bitcoin,MeshCollider/bitcoin,sebrandon1/bitcoin,r8921039/bitcoin,afk11/bitcoin,n1bor/bitcoin,bespike/litecoin,jlopp/statoshi,mitchellcash/bitcoin,JeremyRubin/bitcoin,midnightmagic/bitcoin,domob1812/huntercore,yenliangl/bitcoin,thrasher-/litecoin,Bushstar/UFO-Project,AkioNak/bitcoin,rnicoll/bitcoin,EthanHeilman/bitcoin,JeremyRubin/bitcoin,ahmedbodi/vertcoin,qtumproject/qtum,fanquake/bitcoin,TheBlueMatt/bitcoin,myriadteam/myriadcoin,MeshCollider/bitcoin,r8921039/bitcoin,droark/bitcoin,peercoin/peercoin,ElementsProject/elements,bitcoinsSG/bitcoin,BTCGPU/BTCGPU,MeshCollider/bitcoin,vmp32k/litecoin,mitchellcash/bitcoin,AkioNak/bitcoin,CryptArc/bitcoin,cdecker/bitcoin,domob1812/huntercore,myriadcoin/myriadcoin,fanquake/bitcoin,Bushstar/UFO-Project,instagibbs/bitcoin,namecoin/namecore,qtumproject/qtum,prusnak/bitcoin,randy-waterhouse/bitcoin,lateminer/bitcoin,ericshawlinux/bitcoin,cdecker/bitcoin,Sjors/bitcoin,Flowdalic/bitcoin,namecoin/namecoin-core,afk11/bitcoin,fanquake/bitcoin,stamhe/bitcoin,vmp32k/litecoin,n1bor/bitcoin,Flowdalic/bitcoin,namecoin/namecoin-core,practicalswift/bitcoin,GroestlCoin/GroestlCoin,joshrabinowitz/bitcoin,rnicoll/dogecoin,rawodb/bitcoin,donaloconnor/bitcoin,r8921039/bitcoin,mitchellcash/bitcoin,OmniLayer/omnicore,untrustbank/litecoin,namecoin/namecore,afk11/bitcoin,rnicoll/bitcoin,GlobalBoost/GlobalBoost,bitcoin/bitcoin,GroestlCoin/bitcoin,qtumproject/qtum,andreaskern/bitcoin,ElementsProject/elements,litecoin-project/litecoin,litecoin-project/litecoin,GroestlCoin/bitcoin,domob1812/namecore,GroestlCoin/bitcoin,MeshCollider/bitcoin,OmniLayer/omnicore,vertcoin/vertcoin,kazcw/bitcoin,sstone/bitcoin,pstratem/bitcoin,bitcoinsSG/bitcoin,FeatherCoin/Feathercoin,jmcorgan/bitcoin,sstone/bitcoin,digibyte/digibyte,kazcw/bitcoin,cdecker/bitcoin,ahmedbodi/vertcoin,mruddy/bitcoin,namecoin/namecore,namecoin/namecoin-core,gjhiggins/vcoincore,alecalve/bitcoin,n1bor/bitcoin,randy-waterhouse/bitcoin,RHavar/bitcoin,myriadcoin/myriadcoin,GlobalBoost/GlobalBoost,gjhiggins/vcoincore,kallewoof/bitcoin,domob1812/namecore,GroestlCoin/GroestlCoin,donaloconnor/bitcoin,OmniLayer/omnicore,DigitalPandacoin/pandacoin,pataquets/namecoin-core,jmcorgan/bitcoin,Kogser/bitcoin,mm-s/bitcoin,BTCGPU/BTCGPU,peercoin/peercoin,namecoin/namecoin-core,myriadteam/myriadcoin,jlopp/statoshi,Bushstar/UFO-Project,GroestlCoin/GroestlCoin,pataquets/namecoin-core,rawodb/bitcoin,droark/bitcoin,bitcoin/bitcoin,jnewbery/bitcoin,myriadteam/myriadcoin,GroestlCoin/GroestlCoin,achow101/bitcoin,andreaskern/bitcoin,kazcw/bitcoin,FeatherCoin/Feathercoin,bitcoinknots/bitcoin,kazcw/bitcoin,jtimon/bitcoin,pstratem/bitcoin,sstone/bitcoin,jnewbery/bitcoin,cdecker/bitcoin,particl/particl-core,jtimon/bitcoin,MarcoFalke/bitcoin,digibyte/digibyte,Xekyo/bitcoin,randy-waterhouse/bitcoin,stamhe/bitcoin,guncoin/guncoin,ahmedbodi/vertcoin,midnightmagic/bitcoin,domob1812/bitcoin,vertcoin/vertcoin,rnicoll/dogecoin,practicalswift/bitcoin,lbryio/lbrycrd,bitcoinknots/bitcoin,sebrandon1/bitcoin,dscotese/bitcoin,ElementsProject/elements,Xekyo/bitcoin,JeremyRubin/bitcoin,bitcoinsSG/bitcoin,wellenreiter01/Feathercoin,Sjors/bitcoin,sstone/bitcoin,mm-s/bitcoin,joshrabinowitz/bitcoin,gjhiggins/vcoincore,jtimon/bitcoin,thrasher-/litecoin,jonasschnelli/bitcoin,nikkitan/bitcoin,achow101/bitcoin,jmcorgan/bitcoin,sipsorcery/bitcoin,midnightmagic/bitcoin,pataquets/namecoin-core,Xekyo/bitcoin,Christewart/bitcoin,particl/particl-core,jtimon/bitcoin,peercoin/peercoin,Bushstar/UFO-Project,Kogser/bitcoin,h4x3rotab/BTCGPU,achow101/bitcoin,kallewoof/bitcoin,instagibbs/bitcoin,rnicoll/dogecoin,myriadteam/myriadcoin,jmcorgan/bitcoin,jlopp/statoshi,alecalve/bitcoin,donaloconnor/bitcoin,rnicoll/bitcoin,practicalswift/bitcoin,instagibbs/bitcoin,TheBlueMatt/bitcoin,qtumproject/qtum,guncoin/guncoin,GlobalBoost/GlobalBoost,sstone/bitcoin,bitcoinsSG/bitcoin,h4x3rotab/BTCGPU,jambolo/bitcoin,domob1812/namecore,rawodb/bitcoin,joshrabinowitz/bitcoin,bitcoin/bitcoin,achow101/bitcoin,namecoin/namecoin-core,dscotese/bitcoin,Kogser/bitcoin,BTCGPU/BTCGPU,fujicoin/fujicoin,domob1812/huntercore,domob1812/namecore,andreaskern/bitcoin,paveljanik/bitcoin,RHavar/bitcoin,rawodb/bitcoin,sebrandon1/bitcoin,yenliangl/bitcoin,midnightmagic/bitcoin,yenliangl/bitcoin,lbryio/lbrycrd,myriadteam/myriadcoin,Christewart/bitcoin,fanquake/bitcoin,MarcoFalke/bitcoin,GroestlCoin/bitcoin,jonasschnelli/bitcoin,domob1812/namecore,monacoinproject/monacoin,lbryio/lbrycrd,dscotese/bitcoin,qtumproject/qtum,TheBlueMatt/bitcoin,namecoin/namecore,ahmedbodi/vertcoin,apoelstra/bitcoin,mruddy/bitcoin,ElementsProject/elements,kallewoof/bitcoin,litecoin-project/litecoin,thrasher-/litecoin,ericshawlinux/bitcoin,Kogser/bitcoin,MeshCollider/bitcoin,namecoin/namecore,FeatherCoin/Feathercoin,dscotese/bitcoin,fujicoin/fujicoin,EthanHeilman/bitcoin,alecalve/bitcoin,bespike/litecoin,RHavar/bitcoin,apoelstra/bitcoin,vertcoin/vertcoin,tjps/bitcoin,litecoin-project/litecoin,litecoin-project/litecoin,nikkitan/bitcoin,donaloconnor/bitcoin,Sjors/bitcoin,lbryio/lbrycrd,bitcoinknots/bitcoin,alecalve/bitcoin,GroestlCoin/bitcoin,kazcw/bitcoin,yenliangl/bitcoin,kazcw/bitcoin,paveljanik/bitcoin,joshrabinowitz/bitcoin,Flowdalic/bitcoin,pataquets/namecoin-core,Christewart/bitcoin,jnewbery/bitcoin,GroestlCoin/GroestlCoin,wellenreiter01/Feathercoin,ElementsProject/elements,stamhe/bitcoin,domob1812/bitcoin,tjps/bitcoin,thrasher-/litecoin,GlobalBoost/GlobalBoost,ajtowns/bitcoin,yenliangl/bitcoin,guncoin/guncoin,lbryio/lbrycrd,namecoin/namecore,jmcorgan/bitcoin,ajtowns/bitcoin,CryptArc/bitcoin,monacoinproject/monacoin,guncoin/guncoin,mitchellcash/bitcoin,paveljanik/bitcoin,afk11/bitcoin