本文整理汇总了C++中TransactionFramePtr::getResult方法的典型用法代码示例。如果您正苦于以下问题:C++ TransactionFramePtr::getResult方法的具体用法?C++ TransactionFramePtr::getResult怎么用?C++ TransactionFramePtr::getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransactionFramePtr
的用法示例。
在下文中一共展示了TransactionFramePtr::getResult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: txm
Herder::TransactionSubmitStatus
LoadGenerator::TxInfo::execute(Application& app, bool isCreate,
TransactionResultCode& code, int32_t batchSize)
{
auto seqNum = mFrom->getLastSequenceNumber();
mFrom->setSequenceNumber(seqNum + 1);
TransactionFramePtr txf =
transactionFromOperations(app, mFrom->getSecretKey(), seqNum + 1, mOps);
TxMetrics txm(app.getMetrics());
// Record tx metrics.
if (isCreate)
{
while (batchSize--)
{
txm.mAccountCreated.Mark();
}
}
else
{
txm.mPayment.Mark();
txm.mNativePayment.Mark();
}
txm.mTxnAttempted.Mark();
StellarMessage msg;
msg.type(TRANSACTION);
msg.transaction() = txf->getEnvelope();
txm.mTxnBytes.Mark(xdr::xdr_argpack_size(msg));
auto status = app.getHerder().recvTransaction(txf);
if (status != Herder::TX_STATUS_PENDING)
{
CLOG(INFO, "LoadGen")
<< "tx rejected '" << Herder::TX_STATUS_STRING[status]
<< "': " << xdr::xdr_to_string(txf->getEnvelope()) << " ===> "
<< xdr::xdr_to_string(txf->getResult());
if (status == Herder::TX_STATUS_ERROR)
{
code = txf->getResultCode();
}
txm.mTxnRejected.Mark();
}
else
{
app.getOverlayManager().broadcastMessage(msg);
}
return status;
}
示例2: delta
void
applyAllowTrust(Application& app, SecretKey& from, SecretKey& trustor,
SequenceNumber seq, std::string const& currencyCode,
bool authorize, AllowTrustResultCode result)
{
TransactionFramePtr txFrame;
txFrame = createAllowTrust(from, trustor, seq, currencyCode, authorize);
LedgerDelta delta(app.getLedgerManager().getCurrentLedgerHeader());
txFrame->apply(delta, app);
checkTransaction(*txFrame);
REQUIRE(AllowTrustOpFrame::getInnerCode(
txFrame->getResult().result.results()[0]) == result);
}
示例3: iss
void
CommandHandler::testTx(std::string const& params, std::string& retStr)
{
std::map<std::string, std::string> retMap;
http::server::server::parseParams(params, retMap);
auto to = retMap.find("to");
auto from = retMap.find("from");
auto amount = retMap.find("amount");
auto create = retMap.find("create");
Json::Value root;
if (to != retMap.end() && from != retMap.end() && amount != retMap.end())
{
Hash const& networkID = mApp.getNetworkID();
SecretKey toKey, fromKey;
if (to->second == "root")
{
toKey = getRoot(networkID);
}
else
{
toKey = getAccount(to->second.c_str());
}
if (from->second == "root")
{
fromKey = getRoot(networkID);
}
else
{
fromKey = getAccount(from->second.c_str());
}
uint64_t paymentAmount = 0;
std::istringstream iss(amount->second);
iss >> paymentAmount;
root["from_name"] = from->second;
root["to_name"] = to->second;
root["from_id"] = PubKeyUtils::toStrKey(fromKey.getPublicKey());
root["to_id"] = PubKeyUtils::toStrKey(toKey.getPublicKey());
;
root["amount"] = (Json::UInt64)paymentAmount;
SequenceNumber fromSeq = getSeq(fromKey, mApp) + 1;
TransactionFramePtr txFrame;
if (create != retMap.end() && create->second == "true")
{
txFrame = createCreateAccountTx(networkID, fromKey, toKey, fromSeq,
paymentAmount);
}
else
{
txFrame = createPaymentTx(networkID, fromKey, toKey, fromSeq,
paymentAmount);
}
switch (mApp.getHerder().recvTransaction(txFrame))
{
case Herder::TX_STATUS_PENDING:
root["status"] = "pending";
break;
case Herder::TX_STATUS_DUPLICATE:
root["status"] = "duplicate";
break;
case Herder::TX_STATUS_ERROR:
root["status"] = "error";
root["detail"] =
xdr::xdr_to_string(txFrame->getResult().result.code());
break;
default:
assert(false);
}
}
示例4: createOfferOp
static CreateOfferResult
applyCreateOfferHelper(Application& app, LedgerDelta& delta, uint64 offerId,
SecretKey& source, Currency& takerGets,
Currency& takerPays, Price const& price, int64_t amount,
SequenceNumber seq)
{
uint64_t expectedOfferID = delta.getHeaderFrame().getLastGeneratedID() + 1;
if (offerId != 0)
{
expectedOfferID = offerId;
}
TransactionFramePtr txFrame;
txFrame = createOfferOp(offerId, source, takerGets, takerPays, price,
amount, seq);
txFrame->apply(delta, app);
checkTransaction(*txFrame);
auto& results = txFrame->getResult().result.results();
REQUIRE(results.size() == 1);
auto& createOfferResult = results[0].tr().createOfferResult();
if (createOfferResult.code() == CREATE_OFFER_SUCCESS)
{
OfferFrame offer;
auto& offerResult = createOfferResult.success().offer;
auto& offerEntry = offer.getOffer();
switch (offerResult.effect())
{
case CREATE_OFFER_CREATED:
case CREATE_OFFER_UPDATED:
REQUIRE(OfferFrame::loadOffer(source.getPublicKey(),
expectedOfferID, offer,
app.getDatabase()));
REQUIRE(memcmp(&offerEntry, &offerResult.offer(),
sizeof(OfferEntry)) == 0);
REQUIRE(offerEntry.price == price);
REQUIRE(memcmp(&offerEntry.takerGets, &takerGets,
sizeof(Currency)) == 0);
REQUIRE(memcmp(&offerEntry.takerPays, &takerPays,
sizeof(Currency)) == 0);
break;
case CREATE_OFFER_DELETED:
REQUIRE(!OfferFrame::loadOffer(source.getPublicKey(),
expectedOfferID, offer,
app.getDatabase()));
break;
default:
abort();
}
}
return createOfferResult;
}