5

I want to call chainActive.Tip()->nHeight in core.cpp. It is not possible, I am interested in every idea.

https://github.com/LIMXTEC/BitSend/blob/DEV-joshafest/src/core.cpp

Here is an example :

bool GetH()
{   
    int nBlockHeight = chainActive.Tip()->nHeight;  
    if(nBlockHeight < FORKX17_Main_Net ) 
        return true;    
    else 
        return false; 
    }
}

uint256 CBlockHeader::GetHash() const 
{   
    if (GetH())     
    {
        return HashX11(BEGIN(nVersion), END(nNonce)); 
    }
    else    
    {
       return HashX17(BEGIN(nVersion), END(nNonce));    
    }
}

Also that is not possible:

CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev->nHeight <= FORKX17_Main_Net)

enter image description here

  • 1
    Looks like you need to #include "main.h"? – Nate Eldredge Jun 26 '16 at 3:18
  • 1
    Yes I use main.h. #include "core.h" #include "util.h" #include "main.h" #include "uint256.h" – cgminer-0 Jun 26 '16 at 6:53
  • This is due to missing the object of the class which has 'chainActive()' method. So including which ever the file that has the method. In case if it gives further different undefined reference errors; find the file that contains the method; include it; until it compiles ;) – SajithP Dec 25 '17 at 11:57
  • @SajithP chainActive is a variable not a method :) More likely, it's something to do with the makefile, perhaps main.h cannot be included when building -cli instead of the Daemon? Unsure – MeshCollider Dec 25 '17 at 21:40
  • Got it! Then modify the make file to include the object of the class which has the chainActive as a member. e.g 'x.o' where chainActive is a member of class 'x' – SajithP Dec 26 '17 at 2:40
0

As SajithP commented:

modify the makefile to include the object of the class which has the chainActive as a member. e.g 'x.o' where chainActive is a member of class 'x'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.