void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman) { if(!fMasterNode) return; if(fLiteMode) return; // ignore all Monoeci related functionality if(!masternodeSync.IsBlockchainSynced()) return; if(strCommand == NetMsgType::DSACCEPT) { if(pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) { LogPrintf("DSACCEPT -- incompatible version! nVersion: %d\n", pfrom->nVersion); PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman); return; } if(IsSessionReady()) { // too many users in this session already, reject new ones LogPrintf("DSACCEPT -- queue is already full!\n"); PushStatus(pfrom, STATUS_ACCEPTED, ERR_QUEUE_FULL, connman); return; } int nDenom; CTransaction txCollateral; vRecv >> nDenom >> txCollateral; LogPrint("privatesend", "DSACCEPT -- nDenom %d (%s) txCollateral %s", nDenom, CPrivateSend::GetDenominationsToString(nDenom), txCollateral.ToString()); masternode_info_t mnInfo; if(!mnodeman.GetMasternodeInfo(activeMasternode.outpoint, mnInfo)) { PushStatus(pfrom, STATUS_REJECTED, ERR_MN_LIST, connman); return; } if(vecSessionCollaterals.size() == 0 && mnInfo.nLastDsq != 0 && mnInfo.nLastDsq + mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)/5 > mnodeman.nDsqCount) { LogPrintf("DSACCEPT -- last dsq too recent, must wait: addr=%s\n", pfrom->addr.ToString()); PushStatus(pfrom, STATUS_REJECTED, ERR_RECENT, connman); return; } PoolMessage nMessageID = MSG_NOERR; bool fResult = nSessionID == 0 ? CreateNewSession(nDenom, txCollateral, nMessageID, connman) : AddUserToExistingSession(nDenom, txCollateral, nMessageID); if(fResult) { LogPrintf("DSACCEPT -- is compatible, please submit!\n"); PushStatus(pfrom, STATUS_ACCEPTED, nMessageID, connman); return; } else { LogPrintf("DSACCEPT -- not compatible with existing transactions!\n"); PushStatus(pfrom, STATUS_REJECTED, nMessageID, connman); return; } } else if(strCommand == NetMsgType::DSQUEUE) {
std::vector<CounterResult> AMDCounters::GetCounterData(uint32_t sessionID, uint32_t maxSampleIndex, const std::vector<uint32_t> &eventIDs, const std::vector<GPUCounter> &counters) { std::vector<CounterResult> ret; bool isReady = false; const uint32_t timeoutPeriod = 10000; // ms PerformanceTimer timeout; do { isReady = IsSessionReady(sessionID); if(!isReady) { Threading::Sleep(0); PerformanceTimer endTime; if(timeout.GetMilliseconds() > timeoutPeriod) { GPA_LoggingCallback(GPA_LOGGING_ERROR, "GetCounterData failed due to elapsed timeout."); return ret; } } } while(!isReady); for(uint32_t s = 0; s < maxSampleIndex; s++) { for(size_t c = 0; c < counters.size(); c++) { const CounterDescription desc = GetCounterDescription(counters[c]); switch(desc.resultType) { case CompType::UInt: { if(desc.resultByteWidth == sizeof(uint32_t)) { uint32_t value = GetSampleUint32(sessionID, s, counters[c]); if(desc.unit == CounterUnit::Percentage) { value = RDCCLAMP(value, 0U, 100U); } ret.push_back(CounterResult(eventIDs[s], counters[c], value)); } else if(desc.resultByteWidth == sizeof(uint64_t)) { uint64_t value = GetSampleUint64(sessionID, s, counters[c]); if(desc.unit == CounterUnit::Percentage) { value = RDCCLAMP(value, (uint64_t)0, (uint64_t)100); } ret.push_back(CounterResult(eventIDs[s], counters[c], value)); } else { RDCERR("Unexpected byte width %u", desc.resultByteWidth); } } break; case CompType::Float: { float value = GetSampleFloat32(sessionID, s, counters[c]); if(desc.unit == CounterUnit::Percentage) { value = RDCCLAMP(value, 0.0f, 100.0f); } ret.push_back(CounterResult(eventIDs[s], counters[c], value)); } break; case CompType::Double: { double value = GetSampleFloat64(sessionID, s, counters[c]); if(desc.unit == CounterUnit::Percentage) { value = RDCCLAMP(value, 0.0, 100.0); } ret.push_back(CounterResult(eventIDs[s], counters[c], value)); } break; default: RDCASSERT(0); break; }; } } return ret; }