Bitcoin Forum
May 25, 2024, 07:04:45 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin-core - globals in validation.cpp  (Read 141 times)
nkjack (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 1


View Profile
November 30, 2018, 03:49:44 PM
Merited by bones261 (1)
 #1

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]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!