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); } }
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); } }
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; }
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; }
void testSerialization () { testcase ("serialization"); unexpected (sfGeneric.isUseful (), "sfGeneric must not be useful"); SField const& sfTestVL = SField::getField (STI_VL, 255); SField const& sfTestH256 = SField::getField (STI_HASH256, 255); SField const& sfTestU32 = SField::getField (STI_UINT32, 255); SField const& sfTestObject = SField::getField (STI_OBJECT, 255); SOTemplate elements; elements.push_back (SOElement (sfFlags, SOE_REQUIRED)); elements.push_back (SOElement (sfTestVL, SOE_REQUIRED)); elements.push_back (SOElement (sfTestH256, SOE_OPTIONAL)); elements.push_back (SOElement (sfTestU32, SOE_REQUIRED)); STObject object1 (elements, sfTestObject); STObject object2 (object1); unexpected (object1.getSerializer () != object2.getSerializer (), "STObject error 1"); unexpected (object1.isFieldPresent (sfTestH256) || !object1.isFieldPresent (sfTestVL), "STObject error"); object1.makeFieldPresent (sfTestH256); unexpected (!object1.isFieldPresent (sfTestH256), "STObject Error 2"); unexpected (object1.getFieldH256 (sfTestH256) != uint256 (), "STObject error 3"); if (object1.getSerializer () == object2.getSerializer ()) { WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0); WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0); fail ("STObject error 4"); } else { pass (); } object1.makeFieldAbsent (sfTestH256); unexpected (object1.isFieldPresent (sfTestH256), "STObject error 5"); unexpected (object1.getFlags () != 0, "STObject error 6"); unexpected (object1.getSerializer () != object2.getSerializer (), "STObject error 7"); STObject copy (object1); unexpected (object1.isFieldPresent (sfTestH256), "STObject error 8"); unexpected (copy.isFieldPresent (sfTestH256), "STObject error 9"); unexpected (object1.getSerializer () != copy.getSerializer (), "STObject error 10"); copy.setFieldU32 (sfTestU32, 1); unexpected (object1.getSerializer () == copy.getSerializer (), "STObject error 11"); for (int i = 0; i < 1000; i++) { Blob j (i, 2); object1.setFieldVL (sfTestVL, j); Serializer s; object1.add (s); SerialIter it (s.slice()); STObject object3 (elements, it, sfTestObject); unexpected (object1.getFieldVL (sfTestVL) != j, "STObject error"); unexpected (object3.getFieldVL (sfTestVL) != j, "STObject error"); } }