本文整理汇总了C++中LedgerDelta::recordEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ LedgerDelta::recordEntry方法的具体用法?C++ LedgerDelta::recordEntry怎么用?C++ LedgerDelta::recordEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LedgerDelta
的用法示例。
在下文中一共展示了LedgerDelta::recordEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
bool
ManageDataOpFrame::doApply(Application& app, LedgerDelta& delta,
LedgerManager& ledgerManager)
{
if (app.getLedgerManager().getCurrentLedgerVersion() == 3)
{
throw std::runtime_error(
"MANAGE_DATA not supported on ledger version 3");
}
Database& db = ledgerManager.getDatabase();
auto dataFrame =
DataFrame::loadData(mSourceAccount->getID(), mManageData.dataName, db);
if (mManageData.dataValue)
{
if (!dataFrame)
{ // create a new data entry
if (!mSourceAccount->addNumEntries(1, ledgerManager))
{
app.getMetrics()
.NewMeter({"op-manage-data", "invalid", "low reserve"},
"operation")
.Mark();
innerResult().code(MANAGE_DATA_LOW_RESERVE);
return false;
}
dataFrame = std::make_shared<DataFrame>();
dataFrame->getData().accountID = mSourceAccount->getID();
dataFrame->getData().dataName = mManageData.dataName;
dataFrame->getData().dataValue = *mManageData.dataValue;
dataFrame->storeAdd(delta, db);
mSourceAccount->storeChange(delta, db);
}
else
{ // modify an existing entry
delta.recordEntry(*dataFrame);
dataFrame->getData().dataValue = *mManageData.dataValue;
dataFrame->storeChange(delta, db);
}
}
else
{ // delete an existing piece of data
if (!dataFrame)
{
app.getMetrics()
.NewMeter({"op-manage-data", "invalid", "not-found"},
"operation")
.Mark();
innerResult().code(MANAGE_DATA_NAME_NOT_FOUND);
return false;
}
delta.recordEntry(*dataFrame);
mSourceAccount->addNumEntries(-1, ledgerManager);
mSourceAccount->storeChange(delta, db);
dataFrame->storeDelete(delta, db);
}
innerResult().code(MANAGE_DATA_SUCCESS);
app.getMetrics()
.NewMeter({"op-manage-data", "success", "apply"}, "operation")
.Mark();
return true;
}