本文整理汇总了C++中ledger::pointer::getTransactionMeta方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getTransactionMeta方法的具体用法?C++ pointer::getTransactionMeta怎么用?C++ pointer::getTransactionMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ledger::pointer
的用法示例。
在下文中一共展示了pointer::getTransactionMeta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doTx
// {
// transaction: <hex>
// }
Json::Value doTx (RPC::Context& context)
{
context.lock_.unlock ();
if (!context.params_.isMember (jss::transaction))
return rpcError (rpcINVALID_PARAMS);
bool binary = context.params_.isMember (jss::binary) && context.params_[jss::binary].asBool ();
std::string strTransaction = context.params_[jss::transaction].asString ();
if (Transaction::isHexTxID (strTransaction))
{
// transaction by ID
uint256 txid (strTransaction);
Transaction::pointer txn = getApp().getMasterTransaction ().fetch (txid, true);
if (!txn)
return rpcError (rpcTXN_NOT_FOUND);
#ifdef READY_FOR_NEW_TX_FORMAT
Json::Value ret;
ret[jss::transaction] = txn->getJson (0, binary);
#else
Json::Value ret = txn->getJson (0, binary);
#endif
if (txn->getLedger () != 0)
{
Ledger::pointer lgr = context.netOps_.getLedgerBySeq (txn->getLedger ());
if (lgr)
{
bool okay = false;
if (binary)
{
std::string meta;
if (lgr->getMetaHex (txid, meta))
{
ret[jss::meta] = meta;
okay = true;
}
}
else
{
TransactionMetaSet::pointer set;
if (lgr->getTransactionMeta (txid, set))
{
okay = true;
ret[jss::meta] = set->getJson (0);
}
}
if (okay)
ret[jss::validated] = context.netOps_.isValidated (lgr);
}
}
return ret;
}
return rpcError (rpcNOT_IMPL);
}
示例2: doTx
// {
// transaction: <hex>
// }
Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
if (!params.isMember ("transaction"))
return rpcError (rpcINVALID_PARAMS);
bool binary = params.isMember ("binary") && params["binary"].asBool ();
std::string strTransaction = params["transaction"].asString ();
if (Transaction::isHexTxID (strTransaction))
{
// transaction by ID
uint256 txid (strTransaction);
Transaction::pointer txn = getApp().getMasterTransaction ().fetch (txid, true);
if (!txn)
return rpcError (rpcTXN_NOT_FOUND);
#ifdef READY_FOR_NEW_TX_FORMAT
Json::Value ret;
ret["transaction"] = txn->getJson (0, binary);
#else
Json::Value ret = txn->getJson (0, binary);
#endif
if (txn->getLedger () != 0)
{
Ledger::pointer lgr = mNetOps->getLedgerBySeq (txn->getLedger ());
if (lgr)
{
bool okay = false;
if (binary)
{
std::string meta;
if (lgr->getMetaHex (txid, meta))
{
ret["meta"] = meta;
okay = true;
}
}
else
{
TransactionMetaSet::pointer set;
if (lgr->getTransactionMeta (txid, set))
{
okay = true;
ret["meta"] = set->getJson (0);
}
}
if (okay)
ret["validated"] = mNetOps->isValidated (lgr);
}
}
return ret;
}
return rpcError (rpcNOT_IMPL);
}