本文整理汇总了C++中COutPoint::ToStringShort方法的典型用法代码示例。如果您正苦于以下问题:C++ COutPoint::ToStringShort方法的具体用法?C++ COutPoint::ToStringShort怎么用?C++ COutPoint::ToStringShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COutPoint
的用法示例。
在下文中一共展示了COutPoint::ToStringShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
bool CMasternodeBroadcast::Create(const COutPoint& outpoint, const CService& service, const CKey& keyCollateralAddressNew, const CPubKey& pubKeyCollateralAddressNew, const CKey& keyMasternodeNew, const CPubKey& pubKeyMasternodeNew, std::string& strErrorRet, CMasternodeBroadcast& mnbRet)
{
// wait for reindex and/or import to finish
if (fImporting || fReindex) return false;
LogPrint(MCLog::MN, "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, pubKeyMasternodeNew.GetID() = %s\n",
EncodeDestination(CScriptID(GetScriptForDestination(WitnessV0KeyHash(pubKeyCollateralAddressNew.GetID())))),
EncodeDestination(CScriptID(GetScriptForDestination(WitnessV0KeyHash(pubKeyMasternodeNew.GetID())))));
auto Log = [&strErrorRet, &mnbRet](std::string sErr) -> bool {
strErrorRet = sErr;
mnbRet = CMasternodeBroadcast();
return false;
};
CMasternodePing mnp(outpoint);
if (!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew))
return Log(strprintf("Failed to sign ping, masternode=%s", outpoint.ToStringShort()));
mnbRet = CMasternodeBroadcast(service, outpoint, pubKeyCollateralAddressNew, pubKeyMasternodeNew, PROTOCOL_VERSION);
if (!mnbRet.IsValidNetAddr())
return Log(strprintf("Invalid IP address, masternode=%s", outpoint.ToStringShort()));
mnbRet.lastPing = mnp;
if (!mnbRet.Sign(keyCollateralAddressNew))
return Log(strprintf("Failed to sign broadcast, masternode=%s", outpoint.ToStringShort()));
return true;
}
示例2: updateMasternode
void updateMasternode(interfaces::Node& node, const COutPoint& outpoint, int status)
{
qDebug() << "MasternodeTablePriv::updateMasternode" + QString::fromStdString(strprintf("%s-%d", outpoint.hash.ToString(), outpoint.n)) + " " + QString::number(status);
// Find bounds of this masternode in model
QString strOutpoint = QString::fromStdString(outpoint.ToStringShort());
QList<MasternodeTableEntry>::iterator lower = qLowerBound(
cachedMasternodeTable.begin(), cachedMasternodeTable.end(), strOutpoint, outpointEntryLessThan());
QList<MasternodeTableEntry>::iterator upper = qUpperBound(
cachedMasternodeTable.begin(), cachedMasternodeTable.end(), strOutpoint, outpointEntryLessThan());
int lowerIndex = (lower - cachedMasternodeTable.begin());
int upperIndex = (upper - cachedMasternodeTable.begin());
bool inModel = (lower != upper);
switch(status)
{
case CT_NEW:
if(inModel)
{
//must be our own one and we are just at a clean start -> try to update
interfaces::Masternode masternode = node.getMasternode(outpoint);
lower->txhash = QString::fromStdString(masternode.outpoint.hash.ToString());
lower->n = masternode.outpoint.n;
lower->alias = QString::fromStdString(masternode.alias);
lower->address = QString::fromStdString(masternode.address);
lower->protocol = masternode.protocol;
lower->daemon = masternode.daemon;
lower->sentinel = masternode.sentinel;
lower->status = QString::fromStdString(masternode.status);
lower->active = masternode.active;
lower->lastseen = masternode.last_seen;
lower->payee = QString::fromStdString(masternode.payee);
lower->banscore = masternode.banscore;
parent->emitDataChanged(lowerIndex);
break;
}
{
// Find masternode on platform
interfaces::Masternode masternode = node.getMasternode(outpoint);
if(masternode.outpoint == COutPoint())
{
qWarning() << "MasternodeTablePriv::updateMasternode: Warning: Got CT_NEW, but masternode is not on platform: " + QString::fromStdString(strprintf("%s-%d", outpoint.hash.ToString(), outpoint.n)) + " " + QString::number(status);
break;
}
// Added -- insert at the right position
MasternodeTableEntry::Type addressType = translateMasternodeType(
QString::fromStdString(masternode.alias));
MasternodeTableEntry toInsert =
MasternodeTableEntry(
addressType,
QString::fromStdString(masternode.outpoint.hash.ToString()),
masternode.outpoint.n,
QString::fromStdString(masternode.alias),
QString::fromStdString(masternode.address),
masternode.protocol,
masternode.daemon,
masternode.sentinel,
QString::fromStdString(masternode.status),
masternode.active,
masternode.last_seen,
QString::fromStdString(masternode.payee),
masternode.banscore);
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
cachedMasternodeTable.insert(lowerIndex, toInsert);
parent->endInsertRows();
}
break;
case CT_DELETED:
if(!inModel)
{
qWarning() << "MasternodeTablePriv::updateMasternode: Warning: Got CT_DELETED, but masternode is not in model: " + QString::fromStdString(strprintf("%s-%d", outpoint.hash.ToString(), outpoint.n)) + " " + QString::number(status);
break;
}
// Removed -- remove entire masternode from table
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedMasternodeTable.erase(lower, upper);
parent->endRemoveRows();
break;
case CT_UPDATED:
if(!inModel)
{
qWarning() << "MasternodeTablePriv::updateMasternode: Warning: Got CT_UPDATED, but entry is not in model: "+ QString::fromStdString(strprintf("%s-%d", outpoint.hash.ToString(), outpoint.n)) + " " + QString::number(status);
break;
}
{
// Find masternode on platform
interfaces::Masternode masternode = node.getMasternode(outpoint);
//don't remove our own nodes
if(lower->alias == "" && masternode.outpoint == COutPoint())
{
// did we receive a wrong signal? The node got highes priority, delete the entry
qWarning() << "MasternodeTablePriv::updateMasternode: Warning: Got CT_UPDATED, but masternode is not on platform: " + QString::fromStdString(strprintf("%s-%d", outpoint.hash.ToString(), outpoint.n)) + " " + QString::number(status);
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedMasternodeTable.erase(lower, upper);
parent->endRemoveRows();
break;
}
MasternodeTableEntry::Type addressType = translateMasternodeType(
QString::fromStdString(masternode.alias));
//.........这里部分代码省略.........