本文整理汇总了C++中CService::GetPort方法的典型用法代码示例。如果您正苦于以下问题:C++ CService::GetPort方法的具体用法?C++ CService::GetPort怎么用?C++ CService::GetPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CService
的用法示例。
在下文中一共展示了CService::GetPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EncodeAddress
string EncodeAddress(const CService& addr)
{
struct ircaddr tmp;
if (addr.GetInAddr(&tmp.ip))
{
tmp.port = htons(addr.GetPort());
vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
return string("u") + EncodeBase58Check(vch);
}
return "";
}
示例2: ConnectSocket
bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
{
const proxyType &proxy = proxyInfo[addrDest.GetNetwork()];
#ifdef USE_NATIVE_I2P
if (addrDest.IsNativeI2P()&&IsI2PEnabled()) {
SOCKET streamSocket = I2PSession::Instance().connect(addrDest.GetI2PDestination(), false/*, streamSocket*/);
if (SetSocketOptions(streamSocket)) {
hSocketRet = streamSocket;
return true;
}
return false;
}
#endif
// no proxy needed
if (!proxy.second)
return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout);
SOCKET hSocket = INVALID_SOCKET;
// first connect to proxy server
if (!ConnectSocketDirectly(proxy.first, hSocket, nTimeout))
return false;
// do socks negotiation
switch (proxy.second) {
case 4:
if (!Socks4(addrDest, hSocket))
return false;
break;
case 5:
if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
return false;
break;
default:
return false;
}
hSocketRet = hSocket;
return true;
}
示例3: ProcessMessageMasternode
void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if (strCommand == "dsee") { //DarkSend Election Entry
if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) {
return;
}
bool fIsInitialDownload = IsInitialBlockDownload();
if(fIsInitialDownload) return;
CTxIn vin;
CService addr;
CPubKey pubkey;
CPubKey pubkey2;
vector<unsigned char> vchSig;
int64 sigTime;
int count;
int current;
int64 lastUpdated;
vRecv >> vin >> addr >> vchSig >> sigTime >> pubkey >> pubkey2 >> count >> current >> lastUpdated;
bool isLocal = false; // addr.IsRFC1918();
std::string vchPubKey(pubkey.begin(), pubkey.end());
std::string vchPubKey2(pubkey2.begin(), pubkey2.end());
CScript pubkeyScript;
pubkeyScript.SetDestination(pubkey.GetID());
if(pubkeyScript.size() != 25) {
LogPrintf("dsee - pubkey the wrong size\n");
pfrom->Misbehaving(100);
return;
}
std::string strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2;
CScript pubkeyScript2;
pubkeyScript2.SetDestination(pubkey2.GetID());
if(pubkeyScript2.size() != 25) {
LogPrintf("dsee - pubkey the wrong size\n");
pfrom->Misbehaving(100);
return;
}
std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){
LogPrintf("dsee - Got bad masternode address signature\n");
pfrom->Misbehaving(100);
return;
}
if((fTestNet && addr.GetPort() != 19999) || (!fTestNet && addr.GetPort() != 9999)) return;
//LogPrintf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) {
//LogPrintf(" -- %s\n", mn.vin.ToString().c_str());
if(mn.vin.prevout == vin.prevout) {
//count == -1 when it's a new entry
// e.g. We don't want the entry relayed/time updated when we're syncing the list
if(count == -1 && !mn.UpdatedWithin(MASTERNODE_MIN_SECONDS)){
mn.UpdateLastSeen();
if(mn.now < sigTime){ //take the newest entry
LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str());
mn.pubkey2 = pubkey2;
mn.now = sigTime;
mn.sig = vchSig;
if(pubkey2 == activeMasternode.pubkeyMasterNode2){
activeMasternode.EnableHotColdMasterNode(vin, sigTime, addr);
}
RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated);
}
}
return;
}
}
if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) {
LogPrintf("dsee - Got mismatched pubkey and vin\n");
pfrom->Misbehaving(100);
return;
}
LogPrintf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str());
CValidationState state;
CTransaction tx = CTransaction();
CTxOut vout = CTxOut(999.99*COIN, darkSendPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);
if(tx.AcceptableInputs(state, true)){
LogPrintf("dsee - Accepted masternode entry %i %i\n", count, current);
if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){
//.........这里部分代码省略.........