Bitcoin Forum
March 28, 2024, 10:38:30 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Bitcoin-core - globals in validation.cpp on: November 30, 2018, 03:49:44 PM
Hey,

I have tried to understand the validation.cpp in the bitcoin core more deeply and there is something that I don't understand.

In the validation.cpp there is a instance of CChainState g_chainstate storing CChain chainActive and BlockMap mapBlockIndex.

In addition there are global variables instantiated outside the CChainState class, two of them are:

BlockMap& mapBlockIndex = g_chainstate.mapBlockIndex;
CChain& chainActive = g_chainstate.chainActive;

Why is it coded that why? why not making the mapBlockIndex and chainActive just static variables in the CChainState class?

It seems to me that these variables are not necessarily have to be global variables, but I might miss something.

Thank you very much.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!