Can*t call chainActive.Tip()->nHeight in core.cpp

5

1

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

cgminer-0

Posted 2016-06-25T21:48:19.453

Reputation: 59

1Looks like you need to #include "main.h"?Nate Eldredge 2016-06-26T03:18:30.813

1Yes I use main.h.

include "core.h"

include "util.h"

include "main.h"

include "uint256.h"< – cgminer-0 2016-06-26T06:53:20.953

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 2017-12-25T11:57:33.363

@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? UnsureMeshCollider 2017-12-25T21:40:17.053

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 2017-12-26T02:40:22.560

Answers

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'

RedGrittyBrick

Posted 2016-06-25T21:48:19.453

Reputation: 4 815