void CDarkSendRelay::RelayThroughNode(int nRank) { CMasternode* pmn = mnodeman.GetMasternodeByRank(nRank, nBlockHeight, MIN_POOL_PEER_PROTO_VERSION); if(pmn != NULL){ //printf("RelayThroughNode %s\n", pmn->addr.ToString().c_str()); CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, true); if(pnode){ //printf("Connected\n"); pnode->PushMessage("dsr", (*this)); return; } } else { //printf("RelayThroughNode NULL\n"); } }
void CObfuScationRelay::RelayThroughNode(int nRank) { CMasternode* pmn = mnodeman.GetMasternodeByRank(nRank, nBlockHeight, ActiveProtocol()); if (pmn != NULL) { //printf("RelayThroughNode %s\n", pmn->addr.ToString().c_str()); CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, false); if (pnode) { //printf("Connected\n"); pnode->PushMessage("dsr", (*this)); pnode->Release(); return; } } else { //printf("RelayThroughNode NULL\n"); } }
typename AdjacencyList::ListNode *AdjacencyList::ConnectNode(AdjacencyList::ListNode *node, Index b, Scalar weight) { if (node == NULL) { // insert as the last node in the list ListNode * newNode = new ListNode(b, weight); numEdges_++; return newNode; } if (node->idx == b) { // update the existing weight node->weight = weight; return node; } if (node->idx > b) { // insert in the list ListNode * newNode = new ListNode(b, weight, node); numEdges_++; return newNode; } node->next = ConnectNode(node->next, b, weight); return node; }
void CSandStormRelay::RelayThroughNode(int nRank) { CStormnode* psn = snodeman.GetStormnodeByRank(nRank, nBlockHeight, MIN_SANDSTORM_PROTO_VERSION); if(psn != NULL){ //printf("RelayThroughNode %s\n", psn->addr.ToString().c_str()); if(ConnectNode((CAddress)psn->addr, NULL, true)){ //printf("Connected\n"); CNode* pNode = FindNode(psn->addr); if(pNode) { //printf("Found\n"); pNode->PushMessage("ssr", (*this)); return; } } } else { //printf("RelayThroughNode NULL\n"); } }
// // Bootup the masternode, look for a 1000 NODX input and register on the network // void CActiveMasternode::ManageStatus() { std::string errorMessage; if(!fMasterNode) return; if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); //need correct adjusted time to send ping bool fIsInitialDownload = IsInitialBlockDownload(); if(fIsInitialDownload) { status = MASTERNODE_SYNC_IN_PROCESS; LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode.\n"); return; } if(status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS){ status = MASTERNODE_NOT_PROCESSED; } if(status == MASTERNODE_NOT_PROCESSED) { if(strMasterNodeAddr.empty()) { if(!GetLocal(service)) { notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option."; status = MASTERNODE_NOT_CAPABLE; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } } else { service = CService(strMasterNodeAddr); } LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); if(!ConnectNode((CAddress)service, service.ToString().c_str())){ notCapableReason = "Could not connect to " + service.ToString(); status = MASTERNODE_NOT_CAPABLE; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } if(pwalletMain->IsLocked()){ notCapableReason = "Wallet is locked."; status = MASTERNODE_NOT_CAPABLE; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } // Set defaults status = MASTERNODE_NOT_CAPABLE; notCapableReason = "Unknown. Check debug.log for more information.\n"; // Choose coins to use CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){ LogPrintf("CActiveMasternode::ManageStatus() - Input must have least %d confirmations - %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS, GetInputAge(vin)); status = MASTERNODE_INPUT_TOO_NEW; return; } LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n"); status = MASTERNODE_IS_CAPABLE; notCapableReason = ""; pwalletMain->LockCoin(vin.prevout); // send to all nodes CPubKey pubKeyMasternode; CKey keyMasternode; if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) { LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); return; } if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) { LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str()); } return; } else { LogPrintf("CActiveMasternode::ManageStatus() - Could not find suitable coins!\n"); } } //send to all peers if(!Dseep(errorMessage)) { LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s", errorMessage.c_str()); } }
// // Bootup the Masternode, look for a 1000DRK input and register on the network // void CActiveMasternode::ManageStatus() { std::string errorMessage; if(!fMasterNode) return; if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); //need correct blocks to send ping if(Params().NetworkID() != CBaseChainParams::REGTEST && !masternodeSync.IsBlockchainSynced()) { status = ACTIVE_MASTERNODE_SYNC_IN_PROCESS; LogPrintf("CActiveMasternode::ManageStatus() - %s\n", GetStatus()); return; } if(status == ACTIVE_MASTERNODE_SYNC_IN_PROCESS) status = ACTIVE_MASTERNODE_INITIAL; if(status == ACTIVE_MASTERNODE_INITIAL) { CMasternode *pmn; pmn = mnodeman.Find(pubKeyMasternode); if(pmn != NULL) { pmn->Check(); if(pmn->IsEnabled() && pmn->protocolVersion == PROTOCOL_VERSION) EnableHotColdMasterNode(pmn->vin, pmn->addr); } } if(status != ACTIVE_MASTERNODE_STARTED) { // Set defaults status = ACTIVE_MASTERNODE_NOT_CAPABLE; notCapableReason = ""; if(pwalletMain->IsLocked()){ notCapableReason = "Wallet is locked."; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } if(pwalletMain->GetBalance() == 0){ notCapableReason = "Hot node, waiting for remote activation."; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } if(strMasterNodeAddr.empty()) { if(!GetLocal(service)) { notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option."; LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } } else { service = CService(strMasterNodeAddr); } if(Params().NetworkID() == CBaseChainParams::MAIN) { if(service.GetPort() != 9999) { notCapableReason = strprintf("Invalid port: %u - only 9999 is supported on mainnet.", service.GetPort()); LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } } else if(service.GetPort() == 9999) { notCapableReason = strprintf("Invalid port: %u - 9999 is only supported on mainnet.", service.GetPort()); LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString()); CNode *pnode = ConnectNode((CAddress)service, NULL, false); if(!pnode){ notCapableReason = "Could not connect to " + service.ToString(); LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason); return; } pnode->Release(); // Choose coins to use CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){ status = ACTIVE_MASTERNODE_INPUT_TOO_NEW; notCapableReason = strprintf("%s - %d confirmations", GetStatus(), GetInputAge(vin)); LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason); return; } LOCK(pwalletMain->cs_wallet); pwalletMain->LockCoin(vin.prevout); // send to all nodes CPubKey pubKeyMasternode; CKey keyMasternode; if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) { notCapableReason = "Error upon calling SetKey: " + errorMessage; LogPrintf("Register::ManageStatus() - %s\n", notCapableReason); return; } if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) { notCapableReason = "Error on Register: " + errorMessage; LogPrintf("Register::ManageStatus() - %s\n", notCapableReason); return; } LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n"); status = ACTIVE_MASTERNODE_STARTED; return; } else { notCapableReason = "Could not find suitable coins!"; LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason); return; } } //send to all peers if(!SendMasternodePing(errorMessage)) { LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s\n", errorMessage); } }
// // Bootup the Throne, look for a 1000DRK input and register on the network // void CActiveThrone::ManageStatus() { std::string errorMessage; if(!fThroNe) return; if (fDebug) LogPrintf("CActiveThrone::ManageStatus() - Begin\n"); //need correct adjusted time to send ping bool fIsInitialDownload = IsInitialBlockDownload(); if(fIsInitialDownload) { status = THRONE_SYNC_IN_PROCESS; LogPrintf("CActiveThrone::ManageStatus() - Sync in progress. Must wait until sync is complete to start Throne.\n"); return; } if(status == THRONE_INPUT_TOO_NEW || status == THRONE_NOT_CAPABLE || status == THRONE_SYNC_IN_PROCESS){ status = THRONE_NOT_PROCESSED; } if(status == THRONE_NOT_PROCESSED) { if(strThroNeAddr.empty()) { if(!GetLocal(service)) { notCapableReason = "Can't detect external address. Please use the Throneaddr configuration option."; status = THRONE_NOT_CAPABLE; LogPrintf("CActiveThrone::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } } else { service = CService(strThroNeAddr); } LogPrintf("CActiveThrone::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); if(Params().NetworkID() == CChainParams::MAIN){ if(service.GetPort() != 9340) { notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " - only 9999 is supported on mainnet."; status = THRONE_NOT_CAPABLE; LogPrintf("CActiveThrone::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } } else if(service.GetPort() == 9340) { notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " - 9999 is only supported on mainnet."; status = THRONE_NOT_CAPABLE; LogPrintf("CActiveThrone::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } if(!ConnectNode((CAddress)service, service.ToString().c_str())){ notCapableReason = "Could not connect to " + service.ToString(); status = THRONE_NOT_CAPABLE; LogPrintf("CActiveThrone::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } if(pwalletMain->IsLocked()){ notCapableReason = "Wallet is locked."; status = THRONE_NOT_CAPABLE; LogPrintf("CActiveThrone::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } // Set defaults status = THRONE_NOT_CAPABLE; notCapableReason = "Unknown. Check debug.log for more information.\n"; // Choose coins to use CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; if(GetThroNeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { if(GetInputAge(vin) < THRONE_MIN_CONFIRMATIONS){ notCapableReason = "Input must have least " + boost::lexical_cast<string>(THRONE_MIN_CONFIRMATIONS) + " confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations"; LogPrintf("CActiveThrone::ManageStatus() - %s\n", notCapableReason.c_str()); status = THRONE_INPUT_TOO_NEW; return; } LogPrintf("CActiveThrone::ManageStatus() - Is capable throne node!\n"); status = THRONE_IS_CAPABLE; notCapableReason = ""; pwalletMain->LockCoin(vin.prevout); // send to all nodes CPubKey pubKeyThrone; CKey keyThrone; if(!darkSendSigner.SetKey(strThroNePrivKey, errorMessage, keyThrone, pubKeyThrone)) { LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); return; } if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyThrone, pubKeyThrone, errorMessage)) { LogPrintf("CActiveThrone::ManageStatus() - Error on Register: %s\n", errorMessage.c_str()); } return; } else { notCapableReason = "Could not find suitable coins!"; LogPrintf("CActiveThrone::ManageStatus() - %s\n", notCapableReason.c_str()); } } //send to all peers if(!Dseep(errorMessage)) { LogPrintf("CActiveThrone::ManageStatus() - Error on Ping: %s\n", errorMessage.c_str()); } }
// // Bootup the blanknode, look for a 1000 FNX input and register on the network // void CActiveBlanknode::ManageStatus() { std::string errorMessage; if(!fBlankNode) return; if (fDebug) LogPrintf("CActiveBlanknode::ManageStatus() - Begin\n"); //need correct adjusted time to send ping bool fIsInitialDownload = IsInitialBlockDownload(); if(fIsInitialDownload) { status = BLANKNODE_SYNC_IN_PROCESS; LogPrintf("CActiveBlanknode::ManageStatus() - Sync in progress. Must wait until sync is complete to start blanknode.\n"); return; } if(status == BLANKNODE_INPUT_TOO_NEW || status == BLANKNODE_NOT_CAPABLE || status == BLANKNODE_SYNC_IN_PROCESS){ status = BLANKNODE_NOT_PROCESSED; } if(status == BLANKNODE_NOT_PROCESSED) { if(strBlankNodeAddr.empty()) { if(!GetLocal(service)) { notCapableReason = "Can't detect external address. Please use the blanknodeaddr configuration option."; status = BLANKNODE_NOT_CAPABLE; LogPrintf("CActiveBlanknode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } } else { service = CService(strBlankNodeAddr); } LogPrintf("CActiveBlanknode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); // FNXNOTE: There is no logical reason to restrict this to a specific port. Its a peer, what difference does it make. /* if(service.GetPort() != 31000) { notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " -only 31000 is supported on mainnet."; status = BLANKNODE_NOT_CAPABLE; LogPrintf("CActiveBlanknode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } } else if(service.GetPort() == 31000) { notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " - 31000 is only supported on mainnet."; status = BLANKNODE_NOT_CAPABLE; LogPrintf("CActiveBlanknode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } */ if(!ConnectNode((CAddress)service, service.ToString().c_str())){ notCapableReason = "Could not connect to " + service.ToString(); status = BLANKNODE_NOT_CAPABLE; LogPrintf("CActiveBlanknode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } if(pwalletMain->IsLocked()){ notCapableReason = "Wallet is locked."; status = BLANKNODE_NOT_CAPABLE; LogPrintf("CActiveBlanknode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); return; } // Set defaults status = BLANKNODE_NOT_CAPABLE; notCapableReason = "Unknown. Check debug.log for more information.\n"; // Choose coins to use CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; if(GetBlankNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { if(GetInputAge(vin) < BLANKNODE_MIN_CONFIRMATIONS){ notCapableReason = "Input must have least " + boost::lexical_cast<string>(BLANKNODE_MIN_CONFIRMATIONS) + " confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations"; LogPrintf("CActiveBlanknode::ManageStatus() - %s\n", notCapableReason.c_str()); status = BLANKNODE_INPUT_TOO_NEW; return; } LogPrintf("CActiveBlanknode::ManageStatus() - Is capable master node!\n"); status = BLANKNODE_IS_CAPABLE; notCapableReason = ""; pwalletMain->LockCoin(vin.prevout); // send to all nodes CPubKey pubKeyBlanknode; CKey keyBlanknode; if(!zeroSendSigner.SetKey(strBlankNodePrivKey, errorMessage, keyBlanknode, pubKeyBlanknode)) { LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); return; } /* donations are not supported in fantom.conf */ CScript donationAddress = CScript(); int donationPercentage = 0; if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyBlanknode, pubKeyBlanknode, donationAddress, donationPercentage, errorMessage)) { LogPrintf("CActiveBlanknode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str()); } return; } else { LogPrintf("CActiveBlanknode::ManageStatus() - Could not find suitable coins!\n"); } } //send to all peers if(!Sseep(errorMessage)) { LogPrintf("CActiveBlanknode::ManageStatus() - Error on Ping: %s\n", errorMessage.c_str()); } }
void AdjacencyList::Connect(Index a, Index b, Scalar weight) { if (a == b) return; if (a > b) std::swap(a, b); list_[a] = ConnectNode(list_[a], b, weight); list_[b] = ConnectNode(list_[b], a, weight); }