本文整理汇总了C++中STObject类的典型用法代码示例。如果您正苦于以下问题:C++ STObject类的具体用法?C++ STObject怎么用?C++ STObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: st
Blob Manifest::getMasterSignature () const
{
STObject st (sfGeneric);
SerialIter sit (serialized.data (), serialized.size ());
st.set (sit);
return st.getFieldVL (sfMasterSignature);
}
示例2: object
UPTR_T<SerializedType> STObject::deserialize (SerializerIterator& sit, SField::ref name)
{
STObject* o;
UPTR_T<SerializedType> object (o = new STObject (name));
o->set (sit, 1);
return object;
}
示例3:
void
FeeVoteImpl::doValidation (Ledger::ref lastClosedLedger,
STObject& baseValidation)
{
if (lastClosedLedger->getBaseFee () != target_.reference_fee)
{
if (journal_.info) journal_.info <<
"Voting for base fee of " << target_.reference_fee;
baseValidation.setFieldU64 (sfBaseFee, target_.reference_fee);
}
if (lastClosedLedger->getReserve (0) != target_.account_reserve)
{
if (journal_.info) journal_.info <<
"Voting for base resrve of " << target_.account_reserve;
baseValidation.setFieldU32(sfReserveBase, target_.account_reserve);
}
if (lastClosedLedger->getReserveInc () != target_.owner_reserve)
{
if (journal_.info) journal_.info <<
"Voting for reserve increment of " << target_.owner_reserve;
baseValidation.setFieldU32 (sfReserveIncrement,
target_.owner_reserve);
}
}
示例4:
void
FeeVoteImpl::doValidation(
std::shared_ptr<ReadView const> const& lastClosedLedger,
STObject& baseValidation)
{
if (lastClosedLedger->fees().base != target_.reference_fee)
{
if (journal_.info) journal_.info <<
"Voting for base fee of " << target_.reference_fee;
baseValidation.setFieldU64 (sfBaseFee, target_.reference_fee);
}
if (lastClosedLedger->fees().accountReserve(0) != target_.account_reserve)
{
if (journal_.info) journal_.info <<
"Voting for base resrve of " << target_.account_reserve;
baseValidation.setFieldU32(sfReserveBase, target_.account_reserve);
}
if (lastClosedLedger->fees().increment != target_.owner_reserve)
{
if (journal_.info) journal_.info <<
"Voting for reserve increment of " << target_.owner_reserve;
baseValidation.setFieldU32 (sfReserveIncrement,
target_.owner_reserve);
}
}
示例5: BOOST_FOREACH
// make sure the node exists and force its type
BOOST_FOREACH (STObject & it, mNodes)
{
if (it.getFieldH256 (sfLedgerIndex) == node)
{
it.setFName (type);
it.setFieldU16 (sfLedgerEntryType, nodeType);
return;
}
}
示例6: metaData
STObject TransactionMetaSet::getAsObject () const
{
STObject metaData (sfTransactionMetaData);
assert (mResult != 255);
metaData.setFieldU8 (sfTransactionResult, mResult);
metaData.setFieldU32 (sfTransactionIndex, mIndex);
metaData.emplace_back (mNodes);
if (hasDeliveredAmount ())
metaData.setFieldAmount (sfDeliveredAmount, getDeliveredAmount ());
return metaData;
}
示例7: isAccountFieldOkay
// Ensure all account fields are 160-bits
static
bool
isAccountFieldOkay (STObject const& st)
{
for (int i = 0; i < st.getCount(); ++i)
{
auto t = dynamic_cast<STAccount const*>(st.peekAtPIndex (i));
if (t && t->isDefault ())
return false;
}
return true;
}
示例8: equivalentSTObjectSameTemplate
bool STObject::equivalentSTObjectSameTemplate (
STObject const& obj1, STObject const& obj2)
{
assert (obj1.mType != nullptr);
assert (obj1.mType == obj2.mType);
return std::equal (obj1.begin (), obj1.end (), obj2.begin (), obj2.end (),
[] (STBase const& st1, STBase const& st2)
{
return (st1.getSType() == st2.getSType()) &&
st1.isEquivalent (st2);
});
}
示例9: assert
std::vector<STBase const*>
STObject::getSortedFields (STObject const& objToSort)
{
std::vector<STBase const*> sf;
sf.reserve (objToSort.getCount ());
// Choose the fields that we need to sort.
for (detail::STVar const& elem : objToSort.v_)
{
// Pick out the fields and sort them.
STBase const& base = elem.get();
if ((base.getSType () != STI_NOTPRESENT) &&
base.getFName ().shouldInclude (true))
{
sf.push_back (&base);
}
}
// Sort the fields by fieldCode.
std::sort (sf.begin (), sf.end (),
[] (STBase const* a, STBase const* b) -> bool
{
return a->getFName ().fieldCode < b->getFName ().fieldCode;
});
// There should never be duplicate fields in an STObject. Verify that
// in debug mode.
assert (std::adjacent_find (sf.cbegin (), sf.cend ()) == sf.cend ());
return sf;
}
示例10: sEntries
std::pair<std::vector<SignerEntries::SignerEntry>, TER>
SignerEntries::deserialize (
STObject const& obj, beast::Journal journal, std::string const& annotation)
{
std::pair<std::vector<SignerEntry>, TER> s;
if (!obj.isFieldPresent (sfSignerEntries))
{
if (journal.trace) journal.trace <<
"Malformed " << annotation << ": Need signer entry array.";
s.second = temMALFORMED;
return s;
}
auto& accountVec = s.first;
accountVec.reserve (STTx::maxMultiSigners);
STArray const& sEntries (obj.getFieldArray (sfSignerEntries));
for (STObject const& sEntry : sEntries)
{
// Validate the SignerEntry.
if (sEntry.getFName () != sfSignerEntry)
{
journal.trace <<
"Malformed " << annotation << ": Expected SignerEntry.";
s.second = temMALFORMED;
return s;
}
// Extract SignerEntry fields.
AccountID const account = sEntry.getAccountID (sfAccount);
std::uint16_t const weight = sEntry.getFieldU16 (sfSignerWeight);
accountVec.emplace_back (account, weight);
}
s.second = tesSUCCESS;
return s;
}
示例11: vAmendments
void
AmendmentTableImpl::doValidation (Ledger::ref lastClosedLedger,
STObject& baseValidation)
{
amendmentList_t lAmendments = getDesired();
if (lAmendments.empty())
return;
STVector256 vAmendments (sfAmendments);
for (auto const& uAmendment : lAmendments)
vAmendments.push_back (uAmendment);
vAmendments.sort ();
baseValidation.setFieldV256 (sfAmendments, vAmendments);
}
示例12: thread
bool TransactionMetaSet::thread (STObject& node, uint256 const& prevTxID, std::uint32_t prevLgrID)
{
if (node.getFieldIndex (sfPreviousTxnID) == -1)
{
assert (node.getFieldIndex (sfPreviousTxnLgrSeq) == -1);
node.setFieldH256 (sfPreviousTxnID, prevTxID);
node.setFieldU32 (sfPreviousTxnLgrSeq, prevLgrID);
return true;
}
assert (node.getFieldH256 (sfPreviousTxnID) == prevTxID);
assert (node.getFieldU32 (sfPreviousTxnLgrSeq) == prevLgrID);
return false;
}
示例13: mTransactionID
TxMeta::TxMeta (uint256 const& txid, std::uint32_t ledger, STObject const& obj,
beast::Journal j)
: mTransactionID (txid)
, mLedger (ledger)
, mNodes (obj.getFieldArray (sfAffectedNodes))
, j_ (j)
{
mResult = obj.getFieldU8 (sfTransactionResult);
mIndex = obj.getFieldU32 (sfTransactionIndex);
auto affectedNodes = dynamic_cast <STArray const*>
(obj.peekAtPField (sfAffectedNodes));
assert (affectedNodes);
if (affectedNodes)
mNodes = *affectedNodes;
if (obj.isFieldPresent (sfDeliveredAmount))
setDeliveredAmount (obj.getFieldAmount (sfDeliveredAmount));
}
示例14: isMemoOkay
static
bool
isMemoOkay (STObject const& st, std::string& reason)
{
if (!st.isFieldPresent (sfMemos))
return true;
auto const& memos = st.getFieldArray (sfMemos);
// The number 2048 is a preallocation hint, not a hard limit
// to avoid allocate/copy/free's
Serializer s (2048);
memos.add (s);
// FIXME move the memo limit into a config tunable
if (s.getDataLength () > 1024)
{
reason = "The memo exceeds the maximum allowed size.";
return false;
}
for (auto const& memo : memos)
{
auto memoObj = dynamic_cast <STObject const*> (&memo);
if (!memoObj || (memoObj->getFName() != sfMemo))
{
reason = "A memo array may contain only Memo objects.";
return false;
}
for (auto const& memoElement : *memoObj)
{
auto const& name = memoElement.getFName();
if (name != sfMemoType &&
name != sfMemoData &&
name != sfMemoFormat)
{
reason = "A memo may contain only MemoType, MemoData or "
"MemoFormat fields.";
return false;
}
// The raw data is stored as hex-octets, which we want to decode.
auto data = strUnHex (memoElement.getText ());
if (!data.second)
{
reason = "The MemoType, MemoData and MemoFormat fields may "
"only contain hex-encoded data.";
return false;
}
if (name == sfMemoData)
continue;
// The only allowed characters for MemoType and MemoFormat are the
// characters allowed in URLs per RFC 3986: alphanumerics and the
// following symbols: -._~:/?#[]@!$&'()*+,;=%
static std::array<char, 256> const allowedSymbols = []
{
std::array<char, 256> a;
a.fill(0);
std::string symbols (
"0123456789"
"-._~:/?#[]@!$&'()*+,;=%"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz");
for(char c : symbols)
a[c] = 1;
return a;
}();
for (auto c : data.first)
{
if (!allowedSymbols[c])
{
reason = "The MemoType and MemoFormat fields may only "
"contain characters that are allowed in URLs "
"under RFC 3986.";
return false;
}
}
}
}
return true;
}
示例15: doApply
TER doApply () override
{
Account const refereeID (mTxn.getFieldAccount160 (sfDestination));
Account const referenceID (mTxnAccountID);
if (!refereeID)
{
m_journal.warning <<
"Malformed transaction: Referee account not specified.";
return temDST_NEEDED;
}
else if (referenceID == refereeID)
{
// You're referring yourself.
m_journal.trace <<
"Malformed transaction: Redundant transaction:" <<
" reference=" << to_string(referenceID) <<
" referee=" << to_string(refereeID);
return temREDUNDANT;
}
//
// Open a ledger for editing.
SLE::pointer sleReferee(mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(refereeID)));
SLE::pointer sleReference(mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(referenceID)));
if (!sleReferee) {
// Referee account does not exist.
m_journal.trace <<
"Malformed transaction: Referee account does not exist.";
return tecNO_DST;
} else if (!sleReference) {
// Reference account does not exist.
m_journal.trace <<
"Malformed transaction: Reference account does not exist.";
return terNO_ACCOUNT;
} else if (sleReference->getFieldAccount(sfReferee).getAccountID().isNonZero())
{
// The tag is basically account-specific information we don't
// understand, but we can require someone to fill it in.
// We didn't make this test for a newly-formed account because there's
// no way for this field to be set.
m_journal.trace << "Malformed transaction: Referee has been set.";
return tefREFEREE_EXIST;
}
else
{
// Tell the engine that we are intending to change the the destination
// account. The source account gets always charged a fee so it's always
// marked as modified.
STArray references = sleReferee->getFieldArray(sfReferences);
for (auto it = references.begin(); it != references.end(); ++it) {
Account id = it->getFieldAccount(sfReference).getAccountID();
if (id == referenceID) {
m_journal.trace << "Malformed transaction: Reference has been set.";
return tefREFERENCE_EXIST;
}
}
mEngine->entryModify(sleReference);
mEngine->entryModify(sleReferee);
sleReference->setFieldAccount(sfReferee, refereeID);
STObject obj;
obj.setFieldAccount(sfReference, referenceID);
references.push_back(obj);
sleReferee->setFieldArray(sfReferences, references);
}
return tesSUCCESS;
}