src/fn-service.cpp
/* 
    Fundamentalnode -  Service

    Here we follow Dash strictly.

    -- What it checks

    1.) Making sure Fundamentalnodes have their ports open
    2.) Are responding to requests made by the network


*/
Service
Here we follow Dash strictly.



1.) Making sure Fundamentalnodes have their ports open
2.) Are responding to requests made by the network
Service Here we follow Dash strictly . 1 . ) Making sure Fundamentalnodes have their ports open 2 . ) Are responding to requests made by the network
void ProcessMessageFundamentalnodePOS(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
    if(fProMode) return;
    if(!IsSporkActive(SPORK_7_FUNDAMENTALNODE_SCANNING)) return;
    if(IsInitialBlockDownload()) return;
    if (strCommand == "fnse") 
    {
        CDataStream vMsg(vRecv);
        CFundamentalnodeScanningError fnse;
        vRecv >> fnse;
        CInv inv(MSG_FUNDAMENTALNODE_SCANNING_ERROR, fnse.GetHash());
        pfrom->AddInventoryKnown(inv);
        if(mapFundamentalnodeScanningErrors.count(fnse.GetHash())){
            return;
        }
        mapFundamentalnodeScanningErrors.insert(make_pair(fnse.GetHash(), fnse));
        if(!fnse.IsValid())
        {
            LogPrintf("FundamentalnodePOS::fnse - Invalid object\n");
            return;
        }
        CFundamentalnode* pfnA = fnmanager.Find(fnse.vinFundamentalnodeA);
        if(pfnA == NULL) return;
        if(pfnA->protocolVersion < MIN_FUNDAMENTALNODE_POS_PROTO_VERSION) return;
        int nBlockHeight = pindexBest->nHeight;
        if(nBlockHeight - fnse.nBlockHeight > 10){
            LogPrintf("FundamentalnodePOS::fnse - Too old\n");
            return;   
        }
        int a = fnmanager.GetFundamentalnodeRank(fnse.vinFundamentalnodeA, fnse.nBlockHeight, MIN_FUNDAMENTALNODE_POS_PROTO_VERSION);
        if(a == -1 || a > GetCountScanningPerBlock())
        {
            if(a != -1) LogPrintf("FundamentalnodePOS::fnse - FundamentalnodeA ranking is too high\n");
            return;
        }
        int b = fnmanager.GetFundamentalnodeRank(fnse.vinFundamentalnodeB, fnse.nBlockHeight, MIN_FUNDAMENTALNODE_POS_PROTO_VERSION, false);
        if(b == -1 || b < fnmanager.CountFundamentalnodesAboveProtocol(MIN_FUNDAMENTALNODE_POS_PROTO_VERSION)-GetCountScanningPerBlock())
        {
            if(b != -1) LogPrintf("FundamentalnodePOS::fnse - FundamentalnodeB ranking is too low\n");
            return;
        }
        if(!fnse.SignatureValid()){
            LogPrintf("FundamentalnodePOS::fnse - Bad fundamentalnode message\n");
            return;
        }
        CFundamentalnode* pfnB = fnmanager.Find(fnse.vinFundamentalnodeB);
        if(pfnB == NULL) return;
        if(fDebug) LogPrintf("ProcessMessageFundamentalnodePOS::fnse - nHeight %d FundamentalnodeA %s FundamentalnodeB %s\n", fnse.nBlockHeight, pfnA->addr.ToString().c_str(), pfnB->addr.ToString().c_str());
        pfnB->ApplyScanningError(fnse);
        fnse.Relay();
    }
}
void ProcessMessageFundamentalnodePOS ( CNode * pfrom , std :: string & strCommand , CDataStream & vRecv ) { if ( fProMode ) return ; if ( ! IsSporkActive ( SPORK_7_FUNDAMENTALNODE_SCANNING ) ) return ; if ( IsInitialBlockDownload ( ) ) return ; if ( strCommand == " " ) { CDataStream vMsg ( vRecv ) ; CFundamentalnodeScanningError fnse ; vRecv >> fnse ; CInv inv ( MSG_FUNDAMENTALNODE_SCANNING_ERROR , fnse . GetHash ( ) ) ; pfrom -> AddInventoryKnown ( inv ) ; if ( mapFundamentalnodeScanningErrors . count ( fnse . GetHash ( ) ) ) { return ; } mapFundamentalnodeScanningErrors . insert ( make_pair ( fnse . GetHash ( ) , fnse ) ) ; if ( ! fnse . IsValid ( ) ) { LogPrintf ( " \n " ) ; return ; } CFundamentalnode * pfnA = fnmanager . Find ( fnse . vinFundamentalnodeA ) ; if ( pfnA == NULL ) return ; if ( pfnA -> protocolVersion < MIN_FUNDAMENTALNODE_POS_PROTO_VERSION ) return ; int nBlockHeight = pindexBest -> nHeight ; if ( nBlockHeight - fnse . nBlockHeight > 10 ) { LogPrintf ( " \n " ) ; return ; } int a = fnmanager . GetFundamentalnodeRank ( fnse . vinFundamentalnodeA , fnse . nBlockHeight , MIN_FUNDAMENTALNODE_POS_PROTO_VERSION ) ; if ( a == -1 || a > GetCountScanningPerBlock ( ) ) { if ( a != -1 ) LogPrintf ( " \n " ) ; return ; } int b = fnmanager . GetFundamentalnodeRank ( fnse . vinFundamentalnodeB , fnse . nBlockHeight , MIN_FUNDAMENTALNODE_POS_PROTO_VERSION , false ) ; if ( b == -1 || b < fnmanager . CountFundamentalnodesAboveProtocol ( MIN_FUNDAMENTALNODE_POS_PROTO_VERSION ) - GetCountScanningPerBlock ( ) ) { if ( b != -1 ) LogPrintf ( " \n " ) ; return ; } if ( ! fnse . SignatureValid ( ) ) { LogPrintf ( " \n " ) ; return ; } CFundamentalnode * pfnB = fnmanager . Find ( fnse . vinFundamentalnodeB ) ; if ( pfnB == NULL ) return ; if ( fDebug ) LogPrintf ( " \n " , fnse . nBlockHeight , pfnA -> addr . ToString ( ) . c_str ( ) , pfnB -> addr . ToString ( ) . c_str ( ) ) ; pfnB -> ApplyScanningError ( fnse ) ; fnse . Relay ( ) ; } }
Fundamentalnode -  Service
Here we follow Dash strictly.
Fundamentalnode - Service Here we follow Dash strictly .
//Fundamentalnode Scanning Error // Lowest fundamentalnodes in rank check the highest each block